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 |
|
rajesha
Starting Member
36 Posts |
Posted - 2003-03-28 : 03:44:46
|
| How can i use the USE inside a stored proc.i want to change the dbname using the use command inside a sp.how can do thatexec 'USE'+@dbnname()is not working can anyone help me... |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-03-28 : 05:25:09
|
| You can't.A stored procedure is an object in a database and therefore operates within that context.You can access objects in another database by qualifying the namedbmane.owner.objectname.You can execute a statement within the context of another database byexec dbname..sp_executesql N'sql statement'Note that for all cross database operations permissions will be checked for the login.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|