3
3
3ds2010-12-08 15:04:27
Stored procedures
3ds, 2010-12-08 15:04:27

Mssql dynamic where inside stored procedure?

Hello mssql monsters and monsters = )
The situation is this: there is a thick stored procedure, there are several temporary tables and everything in general. At the end of the procedure, a table is created with the resulting desired data

DECLARE @search table ( .... )<br/>
INSERT INTO @search (...) select ... union select ....<br/>

I pass the parameter to the storage, the parameter @where [varchar](500)
itself looks something like this:
SET @where = 'SELECT * FROM @search WHERE id &gt; 0 AND name like ''%apple%'''

and at the end of the procedure, I'm trying to do this:
EXEC(@words)
BUT, as you know, exec creates its own context and the code does not see the time. Demian Smith table .
The question is whether it is possible to make this table(@search) inside exec?
How can I choose what I need from this storage? (if you try to make an external temporary table and do it in it, it
INSERT INTO @newTemp exec [dbo].[search_proc]gives an error about nested execs. (In the procedure of this very one, there is already an execution and inserting them into tables - temporary)

Answer the question

In order to leave comments, you need to log in

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question