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.
Author |
Topic |
MyronCope
Starting Member
46 Posts |
Posted - 2011-01-27 : 11:33:37
|
using sql server 2005:I created a UDF that returns a table.When I call this UDF using no case statement it works well buthowever when I call a UDF inside of a case statement, I am getting the following errors<ERROR>Msg 156, Level 15, State 1, Line 7Incorrect syntax near the keyword 'SELECT'.Msg 156, Level 15, State 1, Line 9Incorrect syntax near the keyword 'FROM'.</ERROR>The code I'm trying to use follows:[code]SELECT myValue,CASE myCodeWHEN 'C' THEN SELECT * FROM dbo.fcn_myUDF1(myValue)ENDFROM myTable WHERE ID = '123456' GO[/code |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-01-27 : 11:57:41
|
A case statement returns a value not a resultset.trySELECT myValue,CASE myCodeWHEN 'C' THEN(SELECT top 1 col1 FROM dbo.fcn_myUDF1(myValue))ENDFROM myTable WHERE ID = '123456'GO==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-27 : 12:45:21
|
can you elaborate on what udf returns?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|