i have a declared a table :
DECLARE @V_TABLE (ROW_ID INT IDENTITY(1,1), CLIENTKEY, UNIQUEIDENTIFIER)
i have tried to use this table in a piece of dynamic sql
SET @SQL = ' INSERT INTO #CLIENTTABLE ( CLIENTKEY )
(SELECT CLIENTKEY FROM '+ @V_TABLE +')'
the code keeps asking me to declare @v_table how can i use this table in the dynamic sql
In your query @V_TABLE is a table variable and not a string variable containing the name of the table. Hence, if the query is prepared like so, it should work.
SET @SQL = ' INSERT INTO #CLIENTTABLE ( CLIENTKEY )
(SELECT CLIENTKEY FROM @V_TABLE')'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.