Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi. Suppose I have 2 selects: select 1 and select 2In select 1 I have a column with 3 rows and each row has the following content: cdrom, memory, clockIn select 2 I have a column with 5 rows:cdrom, memory, clock, hd, osBased on the 2 selects above, can I have another select statement to return only the rows that are different between those 2 selects?In other words, just to retrieve: hd and os»»» Ken.A
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2005-11-17 : 01:17:16
Try this
Declare @cols varchar(1000)Select @cols=Isnull(@cols+',','')+column_name from information_schema.columns ICwhere table_name='table2' and not exists (select * from information_schema.columns where column_name=IC.column_Name and table_name='table1')select @col2='Select ' + @cols+' from table2'Exec(@sql)