SQLTeam.com | Weblogs | Forums

Find rows for an ID where value changes in any of the columns

Hi,

Can anybody please help with writing a query to find rows for an ID where value changes in any of the columns.

I need to display the IDs for all the rows for which the values have changed for 5 columns.

Please find the DDL and sample data below.

the requirement is to display the product_ID for the row where the values have changed for the following 5 columns:

Main_Product

Product_Colour

Product_Size

Tax_Class_ID

Outer_Print_Name

Thanks for your help.

Thanks.

CREATE TABLE Catalog_Data(
[Product_Catalog_ID] [int] IDENTITY(1,1) NOT NULL,
[Main_Product] [varchar](50) NULL,
[Product_Colour] [varchar](50) NULL,
[Product_Size] [varchar](50) NULL,
[Tax_Class_ID] [varchar](10) NULL,
[Outer_Print_Name] [varchar](100) NULL

) ON [PRIMARY]

Insert into Catalog_Data
select '245862118101DRK_SGE', 'Dark Sage', 'One Size', 'standard','Provence'

union all
select '080482153116NAVY','Navy','One Size','standard','Button Spot'
Union all
select '404999999005BLUE_4', 'Sheer Blue','39','exempt','Block Check'
select '184372049100IVORY', 'Ivory','1-2 yr','exempt','Streets'
Union all
select '525478545852', 'Oyster Shell', 'One Size','standard','Guards'

sounds like homework to me. Have you tried CDC?