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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Character mask specification

Author  Topic 

plasmafire
Starting Member

2 Posts

Posted - 2006-05-21 : 23:45:25
[code]SELECT distinct AssAtt.CharValue as shipment_number
FROM AssetAttribute AssAtt
WHERE AssAtt.AttributeName = 'Reference 04'[/code]
is it possible to specify that select only the shipment numbers that are of the format
S<10 numbers> or D<10 numbers> eg: S2000101100 or D2000101100

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-21 : 23:55:27
will this do ?

where AssAtt.CharValue like 'S%'

or do you have more criteria ?


KH

Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2006-05-22 : 00:18:29
Try this:

SELECT * FROM (
SELECT 'S1234567890' AS Product
UNION ALL
SELECT 'S1234' AS Product
UNION ALL
SELECT 'D9876543210' AS Product
UNION ALL
SELECT 'D9876540' AS Product) A
WHERE Product LIKE 'S[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' OR
Product LIKE 'D[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

plasmafire
Starting Member

2 Posts

Posted - 2006-05-22 : 00:36:47
[code]SELECT distinct AssAtt.CharValue as shipment_number
FROM AssetAttribute AssAtt
WHERE AssAtt.AttributeName = 'Reference 04'
AND AssAtt.CharValue like '[S,D][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'[/code]
This works for me :) Thanks a lot buddies
Go to Top of Page
   

- Advertisement -