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
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.