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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-08-30 : 10:41:03
|
| Ereach writes "Creating a sp and want to use fully qualified name. Iwanted the user to supply the servename and database name while executing the sp.Below is part of the code I was attempting to write but not successfully so far. Any help is apprecaited.Declare@ServerName varchar(128) ,@databaseName varchar(128)(select t2.[description] +' from ' + @ServerName + '.' + @databaseName + '.dbo.' + reference_items where t2.keynote = p.keynote) as "status"" |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-08-30 : 10:55:00
|
| my first question is, why in the world would you do this anyways? Enterprise Manager and Query Analyzer already do this for you.For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2006-08-30 : 19:47:23
|
| I agree there is really no reason to do this, but here it isCreate Procedure Test@ServerName Varchar(50),@@databaseName varchar(50)ASdeclare sQuery Varchar(200)set sQuery = 'select t2.[description] from ' + @ServerName + '.' + @databaseName + '.dbo.reference_items'exec(sQuery)/* I didn't leave in your where clause because the tables that were referenced were not declared*/ |
 |
|
|
|
|
|