Accessing a table in a different DB then the stored procedure
-
Hello All, I have 2 SQL2000 DBs on the same server, in DB#1 I have a stored procedure from which I need to get a field from a table that exists in DB#2. Any Ideas, Thanks in advance
-
Hello All, I have 2 SQL2000 DBs on the same server, in DB#1 I have a stored procedure from which I need to get a field from a table that exists in DB#2. Any Ideas, Thanks in advance
Syntax is: [ServerName].[DatabaseName].[Owner].[TableName].[FieldName] So in your Stored Proc your request might look like: SELECT myField FROM myServer.myDatabase.dbo.myTable WHERE myField = 'some value' ServerName can be an ip address, or if it is on the same server - just a different database - you can omit ServerName altogether. Owner is usually 'dbo' -- otherwise substitute the table's owner