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 |
|
rajsequel
Starting Member
8 Posts |
Posted - 2003-08-05 : 04:09:13
|
| Hi all,the below is working fine, but the thing is i want to get the output to a variable,i.e. step 1 is over. want step 2 to complete.step 1======drop proc sp_GetIdgocreate proc sp_GetIdas declare @msql varchar(100) begin set @msql = 'select count(*) from emp' exec(@msql)endstep 2======drop proc sp_GetIdgocreate proc sp_GetIdas declare @msql varchar(100) declare @mid intbegin set @msql = 'select count(*) from emp' set @mid = exec(@msql) endrajesh |
|
|
vganesh76
Yak Posting Veteran
64 Posts |
Posted - 2003-08-05 : 05:04:12
|
| Probably try thisdrop proc sp_GetIdgocreate proc sp_GetIdasdeclare @msql varchar(100) declare @mid intCreate table #temptbl(reccount int)set @msql = 'Insert into #temptbl SELECT count(*) from status ' exec(@msql)select @mid = reccount From #temptbldrop table #temptblselect @midV.GaneshNet Asset Management.Comvganesh76@rediffmail.comEnjoy working |
 |
|
|
Amethystium
Aged Yak Warrior
701 Posts |
Posted - 2003-08-05 : 05:21:50
|
| [code]drop proc sp_GetIdgocreate proc sp_GetIdas declare @msql varchar(100) declare @mid intbegin set @msql = 'select count(*) from emp' set @mid = exec(@msql) end[/code]You can not do the bit in red. Use sp_executesql instead.Something like this would work :[code]declare @msql nvarchar(1000)declare @mid intselect @msql = 'select @mid = count(*) from emp'exec sp_executesql @msql, N'@mid int output', @mid outputselect @mid[/code]----------------Shadow to Light |
 |
|
|
|
|
|