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 |
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2008-02-27 : 08:20:49
|
| HiHow do i execute a function from qry analyzer ?I have a simple function defined in the user functions sectionand when i run this exec Func_name(1,2)it wont run ?Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'function' |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-27 : 08:21:56
|
| Is it scalar function or Table valued function?-- scalar functionselect Func_name(1,2)--tvfselect * from Func_name(1,2)Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-27 : 08:25:26
|
| Also qualify the function name with ownerMadhivananFailing to plan is Planning to fail |
 |
|
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2008-02-27 : 08:37:50
|
| [CODE]CREATE FUNCTION Func2 (@p int, @s int, @c int, @sd int)RETURNS TABLEASRETURN (SELECT distinct i.code, i.cam,i.p_id,i.s_id,i.start_moment,i.status,a.sub_id FROM inter i, ac aWHERE status not in (3,9) AND( (i.p_id = @p AND i.s_id = @s AND i._id = @ca AND a.suid = @sid ) )ANDi.c = a.inselect Func2(10,96,9,999)[/CODE]this wont work ... |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-02-27 : 08:40:13
|
| as Madhi said... you need the owner too i.e. select * from dbo.Func2(10,96,9,999)Em |
 |
|
|
|
|
|
|
|