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 2008 Forums
 Transact-SQL (2008)
 String Range query

Author  Topic 

amitranjan
Starting Member

45 Posts

Posted - 2010-06-10 : 07:01:11
I have to generate a report where my Report Criteria includes Customer Range: ASTA - Emerald : this will display all customer having name ASTA onwards Till Emerald
Date Range: 01/01/2010 04/30/2010
Currency : CDN or UDS

example:
valid customer range are
ASTA
ASTerix
Binocular
Beard and so on...

invalid
AST
Acer
Academic

i think you got what i meant

amit Ranjan

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-06-10 : 07:40:20
[code]
declare @table table (col1 varchar(20))
insert into @table

SELECT 'ASTA' UNION
SELECT 'ASTerix' UNION
SELECT 'Binocular' UNION
SELECT 'Beard' UNION
SELECT 'AST' UNION
SELECT 'Acer' UNION
SELECT 'emerald' UNION
SELECT 'emeralds' UNION
SELECT 'diamond' UNION
SELECT 'Academic'


select * from @table where col1 between 'AST%' and 'Emerald'
[/code]


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

amitranjan
Starting Member

45 Posts

Posted - 2010-06-10 : 07:44:25
quote:
Originally posted by jimf


declare @table table (col1 varchar(20))
insert into @table

SELECT 'ASTA' UNION
SELECT 'ASTerix' UNION
SELECT 'Binocular' UNION
SELECT 'Beard' UNION
SELECT 'AST' UNION
SELECT 'Acer' UNION
SELECT 'emerald' UNION
SELECT 'emeralds' UNION
SELECT 'diamond' UNION
SELECT 'Academic'


select * from @table where col1 between 'AST%' and 'Emerald'



Jim

Everyday I learn something that somebody else already knew



Thanks , same i was looking for...

amit Ranjan
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-06-10 : 08:15:03
You're Welcome.

JIm

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -