tag:blogger.com,1999:blog-5631842633825648646.post4943334739948083894..comments2024-03-26T15:23:31.524+06:00Comments on Asp.Net Tips & Tricks: How can I query from multiple sql server database that exist on different machine?Anonymoushttp://www.blogger.com/profile/01659074394423470024noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-5631842633825648646.post-89812773855283672802011-08-31T18:42:39.909+06:002011-08-31T18:42:39.909+06:00There's a performance caveat to point here. If...There's a performance caveat to point here. If you run on your server a query that has 4 part names (i.e server.database.schema.object) you will not be able to take advantage of statistics, cached plans, etc on the remote server.<br />To ensure you are still performant, I can just think about two options for starting with.<br /><br />1) Use "openquery" (I haven't used "openrowset" or "opendatasource" but I assume they do something similar). In this case, the string with the T-SQL inside will be executed on the remote server and there will be able to take advantage of those things mentioned before<br /><br />2) You can use four-part-names for executing Stored Procedures located on the remote server. Same thing will happen: Query plan will be generated and executed on the remote server.<br /><br />Nice to have someone talking about linked servers!<br /><br />Don RoqueAnonymousnoreply@blogger.com