Linked Server....

Well today, I started the fun filled adventure of managing data from/to a LinkedServer.

During this learning curve, I found plenty of information about how to query from and instert into a Linked server but most of them utilized the OpenQuery TSQL Statement to operate.

One failure of the concepts is to use the inline statement to access the Linked Server.

In my situation, i was linking to a MySQL database offsite.  Below you will find the MSSQL statement patterns to used when utilizing query statements against the Linked Server.

Select:
1:  Select {cols}  
2:  From {LinkedServer}...{table}  
3:  [Conditions]  

Insert:
1:  Insert Into {LinkedServer}...{table} [cols,...]  
2:  Values ([cols,...])  

There are more commands you can use but the point is that the developer/dba is utilizing only the 'server' and 'table' portions of the source information.  This being, as described by Microsoft, as '{server}.{database}.{schema}.{table}' is simply '{linkedserver}...{table}'.  At least for MySQL, they do not broadcast schema information through general access this is mostly handled by the login credentials instead, as i understand the framework.

In summary, instead of building god-aweful string concatenations with double/triple/etc single quotes to try and get the Execute style expression to execute against the remote server, just use the dot system already in place.  Will allow you to operate on the database/tables in the same way as you maybe/are comfortable with.

Comments

Popular posts from this blog

SysInternals - BgInfo for ALL Users

JSON/AJAX Helpers

Acquiring List of controls - Classic JS