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)
 filter criteria issue for different filed

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2013-07-24 : 05:53:49
hi

I am executing query in ssms 2008. when I passing the filter(spart field) criteria I getting all the values for that field.
same is not reflected in the fkart case .

FKART(nvarchar(4),null)
spart(nvarcahr(2),null)

select a.spart,a.FKART from VBRK a LEFT JOIN TVFKT G1 ON a.MANDT = G1.MANDT AND a.FKART = G1.FKART AND G1.SPRAS = 'EN'
where a.SPART between '0' and 'z'
I got the out put like
spart fkart
70 ZDDS
99 ZSTO
20 ZDDS
10 zccn

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-07-24 : 05:55:58
What is your issue? The query returns the result it is told to.



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-24 : 05:59:34
you're not applying any filter on FKART so how do you expect it to show only filtered set as result?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

kond.mohan
Posting Yak Master

213 Posts

Posted - 2013-07-24 : 06:14:34
here I am passing spart value 0 to z but data is getting for all spart values.if I include fkart and passed 0 to z value same not reflected.

mohan
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-07-24 : 06:21:37
Yes, but you are using BETWEEN!
For you, it means ALL rows starting with a numeric zero (ascii 48) up to and including rows starting with z (ascii 122) will be included in your result.

Perhaps you should try to explain again what is wrong?



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -