duchovnick
Programmer
Hi,
I'm having problems with dynamic sql.
I have a table which name i send as a parameter to a stored procedure that runs dynamic sql
code.
I also send a number as a second parameter to that procedure.
What i want the procedure to do is to create a new table that would contain as many rows as
that of which i sent the name as parameter and fill one column with the number i sent as 2nd
parameter.
I wrote the following code:
Running it i get the following error message:
Can anyone tell me please how to get rid of that error message ?
Thanks a lot !
I'm having problems with dynamic sql.
I have a table which name i send as a parameter to a stored procedure that runs dynamic sql
code.
I also send a number as a second parameter to that procedure.
What i want the procedure to do is to create a new table that would contain as many rows as
that of which i sent the name as parameter and fill one column with the number i sent as 2nd
parameter.
I wrote the following code:
Code:
/*EXEC normalize_old j_9,9*/
ALTER PROCEDURE normalize_old @oldy VARCHAR(20), @magazine VARCHAR(10)
AS
BEGIN TRANSACTION
DECLARE @mydynamicSQL VARCHAR(3000)
SET @mydynamicSQL=
'
SELECT
['+@magazine+']
into
mytable
FROM
['+@oldy+']
'
exec(@mydynamicSQL)
COMMIT
GO
Which is the second param i sent.Invalid column name '9'.
Can anyone tell me please how to get rid of that error message ?
Thanks a lot !