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
 General SQL Server Forums
 New to SQL Server Programming
 compare using < <= > >=

Author  Topic 

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-03-22 : 03:07:05

Hey all,

If we use operator < <= > >= to compare NON nummeric, then how it is being compared..? what it returns?
eg : .... WHERE someObj1.UniqueX <= someObj2.UniqueX

considering :-
 
someObj1.UniqueX someObj2.UniqueX
MM1 NN1
MM2 NN2
MM3 NN3




~~~Focus on problem, not solution~~~

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-22 : 03:12:05
it goes by ascii order.

'B' is greater than 'A' etc


KH

Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-03-22 : 03:31:30
oh really? thanks.. but i still couldnt figure out this (with the red font) -->adopted from my cut n paste code :-


SELECT det.ItemStorageID, det.OriginQty AS AVAQty
FROM tblItemDetail AS det
LEFT JOIN #Data AS dat ON dat.FaceValue=det.OriginQty
WHERE dat.MaxItems >= (SELECT COUNT(*) FROM tblItemDetail AS x WHERE x.OriginQty=det.OriginQty
AND x.ItemStorageID >= det.ItemStorageID)


it seems has big impact coz when i remove, the result query becomes nothing
~~~Focus on problem, not solution~~~
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-22 : 03:50:11
can you post a subset of the records from tblItemDetails and #Data ?


KH

Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-03-22 : 03:57:14
here,


from #data
maxItems FaceValue
2 24

from tblItemdetail
ItemStorageID OriginQty
IS06A00248 24.0
IS06A00671 24.0


~~~Focus on problem, not solution~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-03-22 : 04:02:26
and also...

any difference between

CREATE TABLE #Data
and
declare @Data table
????

~~~Focus on problem, not solution~~~
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-22 : 04:46:16
quote:
Originally posted by maya_zakry

and also...

any difference between

CREATE TABLE #Data
and
declare @Data table
????

~~~Focus on problem, not solution~~~



Yes. #Data is temporary table
@Data is table variable

both are not permanent table. They only exists within the context or scope of your stored procedure.

One major different is for temp table you can insert the result of a stored procedure to it

like
insert into #temp( . . .) exec your_stored_procedure

but you can't do this with table variable


KH

Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-03-22 : 20:57:35
thanks.. khtan! that 's a good simple explaination.

~~~Focus on problem, not solution~~~
Go to Top of Page
   

- Advertisement -