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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-13 : 06:27:28
|
hemangi writes "I am writing a cursor in which i want to the address of all .mdb and .ldf files in the all database in sql server current registration. I have all database list in query bye reading them one by one i want to first-set @sql='use ' + @dbnameexec sp_executesql @sql(where @dbname is the variable in which I am fetching Databse from the cursor query one bye one)Above statement no error showsafter this statement again I am Executing the statement set @sql='exec sp_helpfile ' exec sp_executesql @sqlthis statement give me error not find the database file" |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-13 : 06:51:25
|
select @sql = 'exec ' + @dbname + '..sp_helpfile ' exec sp_executesql @sql==========================================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. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-13 : 10:14:52
|
If you use USE then all must be in same scopeset @sql='use ' + @dbname+' exec sp_helpfile ' exec sp_executesql @sqlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|