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
 Syntax needed

Author  Topic 

peerpressure
Starting Member

2 Posts

Posted - 2007-07-04 : 14:21:41
I am querying a SQL Server 2000 server remotely and have couple of small syntax problems using the WHERE Clause in a Select statement

1. I wish to extract all records where the first 2 characters of a Varchar field (postcode) do not start with 2 specific characters (BT)

2. I wish to extract all records where a Char field is not blank (ie has at least 1 character in it)

Many thanks

Mike

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-04 : 14:30:39
1) select * from table1 where col1 not like 'bt%'
2) select * from table1 where datalength(col1) > 0


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

peerpressure
Starting Member

2 Posts

Posted - 2007-07-04 : 16:14:24
Thanks

Works a treat

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-04 : 16:22:24
2) select * from table1 where col1 > ''


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -