duchovnick
Programmer
Hi,
The following code works OK
The trouble is that "mytable" should be inserte a parameter and i need to change it into "t1". When i write this code:
i get an error message saying:
Hoping to find someone to help me with that !
Thanks !
The following code works OK
Code:
/*EXEC dynamic_table create v_9, f_9, 9*/
CREATE PROCEDURE dynamic_table_create @t1 VARCHAR(15), @t2 VARCHAR(15), @m VARCHAR(5)
AS
BEGIN TRANSACTION
DECLARE @myDynamicSQL VARCHAR(900)
SET @myDynamicSQL =
'
SELECT
accountno "accountno",
phone1 "phone1",
phone1 "phone2",
phone1 "phone3",
'+@m+' as [magazine]
INTO
'+@t2+'
FROM
mytable
'
EXEC(@myDynamicSQL)
COMMIT
GO
Code:
CREATE PROCEDURE dynamic_table_create @t1 VARCHAR(15), @t2 VARCHAR(15), @m VARCHAR(5)
AS
BEGIN TRANSACTION
DECLARE @myDynamicSQL VARCHAR(900)
SET @myDynamicSQL =
'
SELECT
accountno "accountno",
phone1 "phone1",
phone1 "phone2",
phone1 "phone3",
'+@m+' as [magazine]
INTO
'+@t2+'
FROM
'+@t1+'
'
EXEC(@myDynamicSQL)
COMMIT
GO
Any idea what can be wrong with me writing:Invalid object name 'v_9'
?FROM
'+@t1+'
Hoping to find someone to help me with that !
Thanks !