Hi
I have an sql query that returns several rows of data. I need to set a flag on all rows if any one row has certain data.
Example
Declare @myTable TABLE(dID int, Data varchar(25), Flag bit)
Insert into @myTable Select 1,'1', 0
Insert into @myTable Select 2,'2', 0
Insert into @myTable Select 3,'3', 0
Insert into @myTable Select 4,'4', 0
Insert into @myTable Select 5,'5', 0
Insert into @myTable Select 6,'6', 0
Insert into @myTable Select 7,'7', 0
Insert into @myTable Select 8,'8', 0
Insert into @myTable Select 9,'9', 0
Insert into @myTable Select 10,'10', 0
Select * from @myTable
If any row has the value of 5 in the data column, that the flag for all rows is to be set to 1.
I'm using SQL server 2008
Andy
A