Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

DATABASE NAME AS PARAMETER IN PROCEDURE Expand / Collapse
Author
Message
Posted Tuesday, June 24, 2008 8:53 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, April 17, 2009 6:52 AM
Points: 15, Visits: 40
HI..
I have multiple databases . In a procedure I want to send Database name as parameter . Then I want to connect that database and execute some queries . Should any one know best solution without using dynamic sql.
Thanks In Advance .........

Regards,
Reji P R
Post #522605
Posted Tuesday, June 24, 2008 9:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:05 AM
Points: 14,802, Visits: 27,276
You have to issue a USE statement or quantify the object names in the queries with the database name. Neither method supports using a parameter which is why all you'll see for this type of operation is dynamic SQL.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #522636
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse