Santhosh (3/4/2009)
Thanks Flo and Gail,but the requirement is
1. to compare two tables
2. in these two tables there are 50 columns
3. 1 or 2 or 3(max) columns are of type NTEXT
4. so excluding those 1 or 2 or 3 columns i need to compare all remaining columns.
Thanks
San
Then it is very easy without column variable
DECLARE @COLUMNS VARCHAR(1000)
DECLARE @Col1 varchar(100), @Col2 varchar(1000)
SELECT @Columns = SubString (( SELECT ', ' + QUOTENAME(Column_name )
from INFORMATION_SCHEMA.columns
WHERE Table_name ='TimeDimension'
AND Data_type != 'Ntext'
FOR XML PATH ( '' ) ), 3, 1000)
EXEC('SELECT '+ @Columns +' FROM TimeDimension')
John Smith