sql server - Querying multiple MS SQL database instances on the same machine -
I'm new to MS SQL and I'm trying to do something that sounds simple but making me crazy is.
I want to write a query to draw data from two databases, each database is a different example on the same DEV machine. (One MS SQL 2008 and other MS SQL 2005). I am using Microsoft SQL Server Management Studio (MSSMS).
I have basic information. I know the format of the query and what I have to do is my big problem is that what is the name of each server?
SELECT LastName FROM [servername1] .CHA2.dbo.Customer union selected from last name [servername2] OBXKites.dbo.Contact ORDER BY LastName
I connect to the server name I MSSMS (DLPT \ HENRY)
and whatever @@ Tried the SERVERNAME
SELECT @ @SERVERNAME DLPT \ Henry
DLPT \ HENRY. CHA2.dbo.Customer
did not work
I tried it without DLPT Henry.HCLAC
Not worked
I need a future The name of the server to use in the query is NAME.
[DLPT \ Henry]. The name CHA2.dbo.Customer
contains a backslash which is usually illegal in the identifier. You are surrounded by illegal names with brackets.
Note that you are only around the server name. In other words, this [DLPT \ Henry]. HHA 2DBO. Customer, [DLPT \ Henry.HCEADODO. Not customer]
Comments
Post a Comment