Copy binary table data from diff servers

Today, before we start an internal demo of our project, we realized that, on a particular table there is no data in the QA server. We have every thing ready, but no the sample data. We just can’t create an insert script from the table and execute the script there, because, there is a column which is binary type. When we generate the script, the binary data type is not able to populate. Then we are struck with a big question of how to transfer the data between servers.

Let me explain you much in detail about our infra structure.

We have a dev DB server for our internal development hosted on 192.168.2.10 <<local ip address; for our convenience >>

We have a test bed for our application and IIS installed on it, let’s say this is 192.168.3.10, which is altogether a different network. And this IIS is connecting to a TestDB Server (let’s say it is hosted on 192.168.3.20), where we migrate our DB scripts to create the database / tables / stored procedure / user defined functions  / blah .. blah .. what not.

Now, this IIS server(192.168.3.10) is connecting to the TestDB(192.168.3.20) on secured connectivity. Our network folks implemented a rule that the x.x.2.x series can’t talk to x.x.3.x series, but not the vice versa. [[This is the trick / loop hole here]] Now that we need to populate the binary data from a table, and we don’t have access.

What all the dev’s do in the begin is to a bing on how to access the remote server to copy data from table. We are not exceptional to this, and we did all kinds of searches. We also googled for the same, unfortunately we end up either creating the LinkedServers. As we couldn’t connect to the remote TestDB server from our DevEnvironment, we couldn’t establish the connectivity. And the our application DBs are not accepting to create a LinkedServer from TestDB server.

after doing lots of trails and found some easy way to populate the data from one server to another with out having to create a Linkage between the servers.

   13 Exec sp_configure 'show advanced options', 1

   14 

   15 Exec sp_configure 'Ad Hoc Distributed Queries', 1

   16 Reconfigure

   17 

   18 insert into UserProfile

   19 select * from OpenDataSource(

   20 'SQLNCLI',

   21 'Data Source=192.168.3.20;User ID=sa;Password=sa'

   22 ).GlobalWebContent.dbo.UserProfile

Pretty neat and simple solution, it took about approximately 4hrs to convince our SQL DBs to execute the above query. 

Comments

Popular posts from this blog

Network Intrusion Detection using Supervised ML technique

Common mistakes by Interviewer

Keep the system active, to avoid the auto lock