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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-22 : 10:17:06
|
| Chris writes "Hi,I'm trying to call a UDF like this:#################SELECT a.PO_NUMBER, a.PO_DATE, a.GL_CODE, (SELECT dept FROM dbo.udfTEST (a.PO_NUMBER, a.GL_CODE)) AS DeptFROM Table1 aGROUP BY a.PO_NUMBER, a.PO_DATE, a.GL_CODE#################The UDF returns a table. The inputs are both varchars of the appropriate size. I include the PO_NUMBER to do join queries.When I attempt to run this, I get an error like "Line 1: Incorrect syntax near '.'."This same query works if I hard code parameters.Sql Server 2000 / Windows NTAny thoughts?Thanks in advance.Chris." |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-09-22 : 10:41:29
|
| A table valued function will not accept column values as input parameters. They must be either literals or local variables.CODO ERGO SUM |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-09-22 : 12:15:25
|
| Why does the UDF return a table? You're trying to use its return value as a column value in the main query so it should be a scalar value function and it would work fine.If you use a table valued function then you use its result as a table and join it to your other data, don't call it in a row where you need a scalar value. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|