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 |
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2007-07-19 : 01:03:03
|
| hi,I have columns in table having range values stored in it liketable name as tblRangecolumn as RangeID,FromRange,ToRangevalues like 11,1,222,5,733,8,944,12,15now my question is how i check the FromRange to ToRange values exists or notthese values are user input like FromRange = 3 and ToRange = 4or FromRange = 10 and ToRange = 11 or FromRange = 11 and ToRange = 12 (these are correct values)If not then these values stored in table and if these values fall in above any range then it should not allowed user to enterlike FromRange = 6 and ToRange = 8 (this is incorrect value)Regards |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-19 : 01:47:51
|
| DECLARE @RangeIDSELECT @RangeID = RangeIDFROM Table1WHERE FromRange <= @FromRange AND ToRange >= @ToRangeIF @RangeID IS NULL PRINT 'Range does not exists.'ELSE PRINT 'Range ' + CAST(@RangeID AS VARCHAR(11) + ' does exists.'Peter LarssonHelsingborg, Sweden |
 |
|
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2007-07-20 : 05:26:48
|
| Hi,As per your reply I tried above query likedeclare @FromRange intDECLARE @RangeID intdeclare @ToRange intset @FromRange = 3set @ToRange = 4set @RangeID = ''SELECT @RangeID = IDFROM tblRangeWHERE RangeI <= @FromRangeAND RangeII >= @ToRangeselect @RangeID-----------------------------it work fine for values set @FromRange = 10set @ToRange = 12but for these values set @FromRange = 3set @ToRange = 6 set @FromRange = 3set @ToRange = 10I am getting wrong output .. i will explain scenario..I have some kind of work chain that I want to assign to my employeessuppose total chain work is from 1 to 12I divide it into like 1 to 3,3 to 5,5 to 8,8 to 9,9 to 10 and lastly 10 to 12 like that..suppose if I assign 1 to 3,3 to 5 to employee ID 11 and 8 to 9,10 to 12 to employee ID 22..now i want to assign another chain of work to another employee and if I give him work chain number 5 to 8 and 4 to 7 then my application will allow only 5 to 8 as valid and for 4 to 7 it should give me message that "these range is not valid work chain"Regardslike work chain numbers |
 |
|
|
|
|
|
|
|