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 |
|
nishithrn
Yak Posting Veteran
58 Posts |
Posted - 2003-01-06 : 09:11:34
|
| Hi How do I get the output of an exec statement into a variably..??I am using the following query...declare @dbsize intdeclare @dbname char (10)declare @sqlcmd varchar(55)set @dbname = 'master'print @dbnameselect @sqlcmd = 'select size from '+@dbname+'.dbo.sysfiles where fileid=1'exec (@sqlcmd)Now, I want to assign the output of the above into a variable. Pls. help.Thanks in advanceNishith |
|
|
Onamuji
Aged Yak Warrior
504 Posts |
Posted - 2003-01-06 : 09:17:22
|
| Reference: sp_executesqlDECLARE @sql NVARCHAR(4000), @size INT, @db NVARCHAR(128)SET @db = N'master'SET @sql = N'SELECT @size=size FROM [' + @db + '].dbo.sysfiles WHERE fileid = 1'EXEC sp_executesql @sql, N'@size INT OUTPUT', @size OUTPUTPRINT @size |
 |
|
|
nishithrn
Yak Posting Veteran
58 Posts |
Posted - 2003-01-07 : 01:08:17
|
| It works, tx a mil for ur Help Onamuji |
 |
|
|
|
|
|