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 |
|
r_sonakiya
Starting Member
25 Posts |
Posted - 2001-12-05 : 12:18:33
|
| I want to create a Stored procedure which I can execute in all the databases I have in that SQLServer without creating that Stored Procedure in each individual Database.How I can do this?Ravi |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2001-12-05 : 12:35:56
|
| create the stored procedure in master named as sp_mySPThen call it bydeclare @cmd varchar(1000)select @cmd = 'exec mydb..sp_executesql N''exec sp_mySP'''exec (@cmd)the mydb..sp_executesql will cause the command to execute in the context of the database.It will pick the SP up from master but be running in the user database.You can build the sp_executesql call dynamically to execute in a list of databases.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|