Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

[RESOLVED] SQL Syntax Help

$
0
0
Hi all,

I'm trying to retrieve SQL data that follows a specific format, using MS SQL 2000. The data looks like the following

Quote_No
-----------
1234-1
1234-2
JAMES
4456-12
PER JOHN



In the above example I want to select only the records that are 4 digits, followed by a dash, followed by 1 or 2 digits. I've been doing the following
Select Quote_No from tbQuote WHERE Quote_No like '[0-9][0-9][0-9][0-9]-[0-9][0-9]'
but I'm getting 4456-12 only. So I changed it to '[0-9][0-9][0-9][0-9]-[0-9]' but now I'm only getting 1234-1 and 1234-2 only.

I've tried many different things, what would be the syntax so I only get the records 1234-1, 1234-2, and 4456-12? Some queries I get errors, such as if I use '[0-9][0-9][0-9][0-9]-[0-9]%' it reports a syntax error converting JAMES to int. Any help would be appreciated. Thanks!

Viewing all articles
Browse latest Browse all 2918

Latest Images

Trending Articles



Latest Images