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 2000 Forums
 Transact-SQL (2000)
 Problem with where clause of view

Author  Topic 

gamaz
Posting Yak Master

104 Posts

Posted - 2010-05-13 : 11:40:53
Hi,
I am creating a view which works fine. However when I am bringing the where clause the veiw cannot parse.
I am not sure why the where clause is creating the issue. I appreciate any help. Thanks

CODE:
SELECT TOP 100 PERCENT dbo.tegCustXRef_Temp3.slsman, dbo.custaddr.name, dbo.customer.Uf_collectr, dbo.customer.RowPointer
FROM dbo.tegCustXRef_Temp3 INNER JOIN
dbo.customer ON dbo.tegCustXRef_Temp3.cust_num = dbo.customer.cust_num AND
dbo.tegCustXRef_Temp3.Cust_Seq = dbo.customer.cust_seq INNER JOIN
dbo.custaddr ON dbo.customer.cust_num = dbo.custaddr.cust_num AND dbo.customer.cust_seq = dbo.custaddr.cust_seq
ORDER BY dbo.tegCustXRef_Temp3.slsman DESC
WHERE dbo.tegCustXRef_Temp3.slsman BETWEEN '900' AND '999'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-13 : 11:45:37
because it should be before ORDER BY


SELECT TOP 100 PERCENT dbo.tegCustXRef_Temp3.slsman, dbo.custaddr.name, dbo.customer.Uf_collectr, dbo.customer.RowPointer
FROM dbo.tegCustXRef_Temp3 INNER JOIN
dbo.customer ON dbo.tegCustXRef_Temp3.cust_num = dbo.customer.cust_num AND
dbo.tegCustXRef_Temp3.Cust_Seq = dbo.customer.cust_seq INNER JOIN
dbo.custaddr ON dbo.customer.cust_num = dbo.custaddr.cust_num AND dbo.customer.cust_seq = dbo.custaddr.cust_seq
WHERE dbo.tegCustXRef_Temp3.slsman BETWEEN '900' AND '999'
ORDER BY dbo.tegCustXRef_Temp3.slsman DESC


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-13 : 11:47:17
might be worth the read

http://visakhm.blogspot.com/2010/01/behaviour-of-order-by-inside-view.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

gamaz
Posting Yak Master

104 Posts

Posted - 2010-05-13 : 11:49:21
Thanks visakh for the quick help. I appreciate it.
It works now.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-13 : 12:39:40
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -