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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Validate values in a column

Author  Topic 

n4nature
Starting Member

7 Posts

Posted - 2011-09-22 : 20:48:17
Hi,

I am new to this forum as well as writing sql queries. However I have come up with a few basic queries including join and am able to retrieve the values that I wanted. Is there a way in sql to iterate through all values of a particular column and verify each one of them? If any of the value falls out of desired range, then the test query fails?

Please let me know if you know the answer.

Thanks,
-Nick

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-22 : 22:25:22
no need to iterate column. you can do check in set based manner. use query like

SELECT CASE WHEN Column BETWEEN @RangeStart AND @RangeEnd THEN 'Pass' ELSE 'Fail' END
FROM table


this will do check for all column values together and then give pass of fail based on criteria. The @RangeStart and @RangeEnd are parameters created through you can pass required start and end values for comparison

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -