Avatar of Ali Shah
Ali Shah
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

How to find a record change and raise a flag in T-SQL

Hi Guys,

I have got a master table which contains the unique records, just like below

JobNo	   BookingStatusID
4363267	   2

Open in new window


I have got a child table as below
JobNo      BookingStatusDescription      WebSupplierStatusID      WebSupplierStatusDescription      RevisionNo      SupplierID
4363267      Amended                                   2                                           Assigned                                             2                 4969
4363267      Confirmed                                   3                                           Rejected                                             1                  5202
4363267      Amended                                   4                                          Accepted                                             4                  4969
4363267      Amended                                   5                                          Error                                                      3                   4969

WIth in my T-SQL I want to figure out that if the supplier ID has been changed then raise some sort of Flag of 0 or 1. I don't want to use inline UDF as the data contains hundred of thousands of rows.

How do i achieve this. Please note i am using SQL Server 2014

regards
Microsoft SQL ServerMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
Ali Shah

8/22/2022 - Mon