Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Dynamic Server Name in T-SQL

Author  Topic 

DMP
Starting Member

41 Posts

Posted - 2004-12-21 : 23:52:09
How can i give the dynamic server reference in my T-SQL ?
Example :

Select * from DynamicServer.pubs.Titles

Here DynamicServer name comes from another table which is a Varchar field.

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2004-12-22 : 01:19:59
use Dynamic SQL.
exec('select * from ' + @DynamicServer_variable + '.pubs..titles')


Hemanth Gorijala
Exchange a Dollar, we still have ONE each._______Exchange an Idea, we both have TWO each.
Go to Top of Page

DMP
Starting Member

41 Posts

Posted - 2004-12-22 : 01:32:27
Thanks hgorijal,
But I need without converting the SQL to String
How is it possible ?
Go to Top of Page

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2004-12-22 : 05:17:56
nope... can't do

Hemanth Gorijala
Exchange a Dollar, we still have ONE each._______Exchange an Idea, we both have TWO each.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-12-22 : 07:27:38
EXEC (@DynamicServer_variable + '.dbo.MyStoredProcedureStoredInThatDatabase')

perhaps?

Kristen
Go to Top of Page
   

- Advertisement -