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 |
tanhs
Starting Member
2 Posts |
Posted - 2005-07-22 : 03:17:36
|
Hi,I am using mssql7.0 I would like to dynamicly change Db in the stored procedureeg.....execute('use master') -- this doesn't workexecute('select * from sysobjects')print db_name()....How should I go about to do this ?Tq. |
|
tanhs
Starting Member
2 Posts |
Posted - 2005-07-22 : 03:24:42
|
sorry here are some changes....execute('use master') -- this doesn't workdeclare cur cursor for select name from sysobejcts where type='U'print db_name().... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-22 : 04:49:12
|
You can useexecute('select * from master..sysobjects')MadhivananFailing to plan is Planning to fail |
|
|
Mala
Starting Member
26 Posts |
Posted - 2005-07-26 : 04:07:02
|
declare @db varchar(10), @sql nvarchar(500)set @db='master'set @sql='select * from '+@db+'..sysobjects'exec (@sql) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-26 : 04:44:08
|
Mala, I think Dynamic SQL is not neccessary in this caseMadhivananFailing to plan is Planning to fail |
|
|
|
|
|