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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reading into temp table using dynamic table

Author  Topic 

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-08-01 : 04:59:09
How can I do something like this:
@temp_table_name is a variable to hold the data table name?
fn_true_csv_split is a UDF

SELECT RowNum ,
WholeRow = dbo.fn_true_csv_split(s.WholeRow,'|')
INTO #StagingB
FROM @temp_table_name

Thanks!

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-08-01 : 05:19:28
Nevermind this works:

declare @temp_table_name varchar(255), @temp_table_name2 varchar(255)
set @temp_table_name = '[staging1]'
set @temp_table_name2 = '[staging2]'
Exec ('SELECT RowNum ,
WholeRow = dbo.fn_true_csv_split(WholeRow,''|'')
INTO ' + @temp_table_name2 + '
FROM ' + @temp_table_name)
Go to Top of Page
   

- Advertisement -