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 |
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 03:15:01
|
| I need to know what is the function of USE ?; in sp_msforeachdb @command1 = "USE ?;select name, type from sys.objects where type in ('U', 'P')" |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-07-16 : 03:17:02
|
| it changes the current database context |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-16 : 03:17:15
|
in sp_msforeachdb ? will be replace by database nameso this will be executed for each of the dbuse <database name>select name, type from sys.objects where type in ('U', 'P') KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-16 : 03:17:55
|
quote: Originally posted by russell it changes the current database context
And this too . . missed out this point. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 03:19:49
|
| 'Use ?' can only be used with sp_msforeachdb is it? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-16 : 03:34:24
|
quote: Originally posted by sharankruthi 'Use ?' can only be used with sp_msforeachdb is it?
The "?" is specially handled in sp_msforeachdb. It will be replace with the database name. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 03:35:28
|
| ok ok thankx.. |
 |
|
|
|
|
|