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 |
|
anoopsinghal80
Starting Member
3 Posts |
Posted - 2005-02-08 : 05:28:42
|
| Dear All,I want to pass a value of column to a User Defined Function which I am using in my query and the value will come from Query based on the result set.Actually I am using a function returning table and using it in join with another table so when I pass the column value to it it givs me Incorrect Syntax.Waitng for you response.RegardsAnoop SinghalDatabase AdministratorAdvent Matrix Inc.www.stonematrix.com |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-02-08 : 06:40:28
|
| Post DDL & DML, the error message and expected resultsAndy |
 |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2005-02-08 : 07:17:35
|
| Hello!You cannot use a table-valued function as you would a scalar function. Sounds as though that's what you are trying to do.You can't do this (for obvious reasons if you think about it):select t.t, t2.valuefrom t1 inner join dbo.func(t.t) t2 on t1.t=t2.tYou'll have to save the value you want to use in a variable first./Andraax |
 |
|
|
anupkansal8
Starting Member
1 Post |
Posted - 2005-02-08 : 08:14:00
|
| TRY THISUSE PUBSGOCreate FUNCTION FN_SALES1 (@QTY FLOAT) RETURNS TABLE ASRETURN (SELECT * FROM SALES WHERE QTY >= @QTY)GOSELECT ST.STOR_NAME,SL.* FROM STORES ST JOIN dbo.FN_SALES1 (40) SL ON ST.STOR_ID=SL.STOR_IDanup |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-02-08 : 08:56:58
|
| Why are you using a UDF? Instead posting what you are trying to do and saying "it won't work!", show us what you have for data (small, revelant sample) and what you are trying to return with that data and why. I doubt you need (or want) to use a UDF.- Jeff |
 |
|
|
|
|
|