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
 SQL Server Development (2000)
 CASE in TRansSQL

Author  Topic 

jesus4u
Posting Yak Master

204 Posts

Posted - 2003-02-12 : 11:38:34
Before I update I want to test whether certain conditions are true but I get the following error.
Why?
Thanks

[error]
Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '>'.
Server: Msg 156, Level 15, State 1, Line 20
Incorrect syntax near the keyword 'as'.
[/error]


UPDATE W
SET Referrer=

CASE Referrer
WHEN CHARINDEX('http://', Y.PR) > 0 THEN REPLACE(Y.PR, 'http://', '')
WHEN CHARINDEX('http://www.', Y.PR) > 0 THEN REPLACE(Y.PR, 'http://www.', '')
ELSE Y.PR
END


FROM WebLog W
INNER JOIN
(SELECT
IP,
(Referrer) as PR
FROM WebLog l
WHERE [Date] =
(SELECT Max([Date])
FROM WebLog
WHERE IP=l.IP)) as Y
ON W.IP=Y.IP


Onamuji
Aged Yak Warrior

504 Posts

Posted - 2003-02-12 : 12:21:31
CASE Referrer <- this only lets you test for certain values

CASE <- this allows you to test with the WHEN clause
WHEN

Go to Top of Page
   

- Advertisement -