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 |
|
Lynnie6
Starting Member
1 Post |
Posted - 2002-11-18 : 11:00:01
|
| The problem with the statement (below) snipped from a stored procedure Ive been using is that previously it worked fine, however more joins have been added to the procedure, and the SELECT query now exceeds 4000 chars. I've been trying to get it to work, by removing sp_executesql, and using EXEC on its own, e.g. EXEC @status2 = (@sql_select + @sql_from + @sql_where + @sql_order_by), N'@known_id INT ,@sort_column NVARCHAR(30)....but my syntax is wrong and I can't figure it out. Can anyone help please? <snip> DECLARE @sql_stmt NVARCHAR (4000)SELECT @sql_stmt = (@sql_select + @sql_from + @sql_where + @sql_order_by)EXEC @status2 = sp_executesql @sql_stmt, N'@known_id INT ,@sort_column NVARCHAR(30) ,@first_var SMALLINT ,@second_var SMALLINT' ,@known_id ,@sort_column ,@first_var ,@second_var <end snip> |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-11-18 : 11:51:16
|
| select the return value at the end of the string (if you need it) and include the parameters in the build of the execute string.crate table #a(i int)insert EXEC (@sql_select + @sql_from + @sql_where + @sql_order_by)select @status2 = i from #adrop table #a==========================================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. |
 |
|
|
|
|
|
|
|