SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Case Statement in UDF
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

murrayb3024
Yak Posting Veteran

79 Posts

Posted - 11/28/2012 :  10:13:21  Show Profile  Reply with Quote
Trying to use a the following case statement in a user defined function but not working

SET @dd = CASE @aTotal
WHEN @aTotal IN (1,10,19,28,37,46,55,64,73,82,91) THEN 8
WHEN @aTotal IN (2,11,20,29,38,47,56,65,74,83,92) THEN 7
WHEN @aTotal IN (3,12,21,30,39,48,57,66,75,84,93) THEN 6
WHEN @aTotal IN (4,13,22,31,40,49,58,67,76,85,94) THEN 5
WHEN @aTotal IN (5,14,23,32,41,50,59,68,77,86,95) THEN 4
WHEN @aTotal IN (6,15,24,33,42,51,60,69,78,87,96) THEN 3
WHEN @aTotal IN (7,16,25,34,43,52,61,70,79,88,97) THEN 2
WHEN @aTotal IN (8,17,26,35,44,53,62,71,80,89,98) THEN 1
ELSE 0
END

Get this error: Incorrect syntax near the keyword 'IN'.

Can you not do an "IN" in a UDF?

Edited by - murrayb3024 on 11/28/2012 10:14:12

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 11/28/2012 :  10:16:18  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by murrayb3024

Trying to use a the following case statement in a user defined function but not working

SET @dd = CASE @aTotal
WHEN @aTotal IN (1,10,19,28,37,46,55,64,73,82,91) THEN 8
WHEN @aTotal IN (2,11,20,29,38,47,56,65,74,83,92) THEN 7
WHEN @aTotal IN (3,12,21,30,39,48,57,66,75,84,93) THEN 6
WHEN @aTotal IN (4,13,22,31,40,49,58,67,76,85,94) THEN 5
WHEN @aTotal IN (5,14,23,32,41,50,59,68,77,86,95) THEN 4
WHEN @aTotal IN (6,15,24,33,42,51,60,69,78,87,96) THEN 3
WHEN @aTotal IN (7,16,25,34,43,52,61,70,79,88,97) THEN 2
WHEN @aTotal IN (8,17,26,35,44,53,62,71,80,89,98) THEN 1
ELSE 0
END

Get this error: Incorrect syntax near the keyword 'IN'.

Can you not do an "IN" in a UDF?




Too old to Rock'n'Roll too young to die.
Go to Top of Page

murrayb3024
Yak Posting Veteran

79 Posts

Posted - 11/28/2012 :  10:20:11  Show Profile  Reply with Quote
wow, totally missed that, thank you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000