Saturday, August 3, 2013

Is there a syntax that will allow me to exclude certain columns versus explicitly stating every column that I want?

You could get the list of columns (comma separated list)for a table using this query. If you know the column names that you want to exclude , you could put them into the where clause in this query and later the column list can be used in dynamic query.


Hope this helps



select Stuff((select
','+c.name
from sys.columns c join
sys.tables t
on t.object_id=c.object_id
for xml xml path()),1,1,'')





Satheesh


No comments:

Post a Comment