SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 if...else not working
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2


United Kingdom
22629 Posts

Posted - 09/23/2006 :  03:15:38  Show Profile  Reply with Quote
Going back to your original query this would work, because it is a boolean test (but it is probably solving a different problem to the one you wanted):

declare @table table(ad_num varchar(20), ad_str1 varchar(20))

insert @table
select '20', '20 apple avenue' union all
select '20', 'apple avenue'

select * from @table

if (EXISTS(select * from @table where substring(ad_str1, 1, 1) like '[0-9]'))

print 'At least one address starts with a number'
print 'None of the addresses starts with a number'

Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000