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-03-02 : 07:56:10
|
| Sheeja M. writes "I want to pass a tablename (tbl_comm_param_new) to this cursor. I tried, and almost got there, but getting the following errorServer: Msg 214, Level 16, State 3, Procedure sp_executesql, Line 20Procedure expects parameter '@parameters' of type 'ntext/nchar/nvarchar'.my cursor is- DECLARE @my_cur CURSOR,@tblv nvarchar,@QRYTORUN nvarchar,@ccount int,@circle nvarchar;beginset @tblv = 'tbl_comm_param_new'select @QRYTORUN = 'SET @my_cur = CURSOR FOR select param_id from ' + @tblv + ' ; OPEN @my_cur'select @QRYTORUN = @QRYTORUN + '@my_cur cursor OUTPUT'-- EXEC sp_executesql-- N'SET @my_cur = CURSOR FOR select param_id from ' + @tblv + ' ; OPEN @my_cur', -- N'@my_cur cursor OUTPUT', @my_cur OUTPUT EXEC sp_executesql @QRYTORUN , @my_cur OUTPUT -- FETCH NEXT FROM @my_curFETCH @my_cur INTO @ccount WHILE @@FETCH_STATUS = 0 BEGIN --loop print @ccount end endregards,Sheeja M." |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-02 : 08:07:05
|
| Give more details on what you are trying to do. There can be better method to do that than you think. Anyway refer this to know about Dynamic SQLhttp://www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|