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 - 2005-08-22 : 07:01:01
|
| Vinod writes "I am building dynamic SQL statement in @SQL variable. I want to execute this statement and want to get the result in some variable say @REC_COUNT. Below is the sample code... USE NorthwindGODECLARE @REC_COUNT INTDECLARE @SQL NVARCHAR(255)SET @SQL = 'SELECT COUNT(*) FROM Employees'EXECUTE sp_executeSQL @SQLCan anybody have any idea? How can I get the value in @REC_COUNT variable..Thanks in advanceVinod" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-08-22 : 08:31:10
|
| declare @i intSET @SQL = 'SELECT @i = COUNT(*) FROM Employees'EXECUTE sp_executeSQL @SQL, N'@i int out', @i outseehttp://www.mindsdoor.net/SQLTsql/sp_executeSQL.html==========================================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. |
 |
|
|
|
|
|