Determining if a column exists in a temp table | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Determining if a column exists in a temp table

I have a temp table where I need to determine if a column already exists in the temp table. I have looked at sp_column with passing the parameters @table_name and @column_name and then testing @@row_count. This works great for a permanent table, but will not work for a temp table. Does anyone know how this can be done? Thanks
Keep in mind once you’re completed with session temp tables will be dissappeared, so its not possible to keep a track on them. Its better to query against syscolumns under temp database for an information. HTH Satya SKJ
]]>