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 comparisons in SQL 2008

Author  Topic 

dkekesi
Starting Member

38 Posts

Posted - 2011-03-31 : 11:45:08
Hi All,

I have a table with 2 columns: IntervalBegin and IntervalEnd. These columns are filled with data like
IntervalBegin IntervalEnd
-----------------------------------
AC7S-V000001 AC7S-V999950
AC7S-W000001 AC7S-W501050
AC8SA0000001 AC8SA0010000
AC8SA0010001 AC8SA0510000
AD7E-A000001 AD7E-A999950
AD7E-B000001 AD7E-B999950
AD7E-C000001 AD7E-C999950
AD7E-D000001 AD7E-D999950

These are intervals for valid account identifiers.
I need to design a stored procedure that returns true if the account identifier supplied in a parameter is between one of the intervals (inclusive). For example with the data above supplying AC7S-W000002 to the SP it would return true, but would return false for AD7E-A999951.
The problem is that the structure of the identifiers are different as you can see in the example above.

Is this totally hopeless and am I better off writing the algorithm on the client side?

Thanks for the help in advance.

Br,
Daniel

Best Regards,
Daniel

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-31 : 11:48:09
[code]
IF EXISTS (SELECT * FROM atable WHERE IntervalBegin <= @parameter AND IntervalEnd >= @parameter )
PRINT 'TRUE'
ELSE
PRINT 'FALSE'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

dkekesi
Starting Member

38 Posts

Posted - 2011-04-01 : 10:53:23
Perfect, thanks a lot for the help.

Best Regards,
Daniel
Go to Top of Page
   

- Advertisement -