I have a select statement that grabs 36 columns from my 40 column table in order to build a cursor on them so that I may compare each field to another table in order to prevent duplicate data from being inserted. Although slow, this process works fine when I only want to check one file at a time. I would like to parameritize this query to accept different table names that I keep in a temp table, but I dont want to recreate the query as a dynamic string. I thought I could put a subquery in the from clause like this :
SELECT COL1, COL2...COL3
FROM (SELECT tablename from FileDetails where tablename = @table)
I get a syntax error ("Line 2: Incorrect syntax near ')' "
Am I wrong in assuming that this can be done? I really do not want to have to place this all in a dynamic string due to the number of columns and their names just might push the 8000 byte limit.
thanks in advance!!
SELECT COL1, COL2...COL3
FROM (SELECT tablename from FileDetails where tablename = @table)
I get a syntax error ("Line 2: Incorrect syntax near ')' "
Am I wrong in assuming that this can be done? I really do not want to have to place this all in a dynamic string due to the number of columns and their names just might push the 8000 byte limit.
thanks in advance!!