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.
| Author |
Topic |
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2007-12-12 : 07:29:31
|
| HiI have a need to somehow create a table where the client enter a number range ex: 456 - 789, how would I create such a table and make those numbers searchable so I can enter a number and see if that number is in the 456-789 range.Regards |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-12 : 07:35:27
|
[code]DECLARE @Sample TABLE (LowNo INT, HighNo INT)INSERT @SampleSELECT 456, 789 UNION ALLSELECT 123, 456DECLARE @Search INTSET @Search = 600SELECT *FROM @SampleWHERE @Search BETWEEN LowNo AND HighNo[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-12 : 07:36:32
|
| Do you want to create a number table with that range?Declare @t table(n int)insert into @t(n)select number from (select row_number() over (order by s1.colid) as number from syscolumns s1 cross join syscolumns s2) as t where number between 456 and 789Select n from @tMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-12 : 07:37:28
|
| I think I misunderstood the questionMadhivananFailing to plan is Planning to fail |
 |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2007-12-12 : 09:08:37
|
| Hi Peso, worked excellent. Thanks! |
 |
|
|
|
|
|