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 |
jawu
Starting Member
7 Posts |
Posted - 2005-08-29 : 06:48:32
|
Hi, I want to call the Function in my Select Query. For that I wanted to create Function but when I tried to Create Function in Query Analyzer I was getting error "Incorrect syntax near 'FUNCTION'". After I have copied the Create function Example given in the help and tried to execute then also giving the same error result. What is the Exact reason? Very Urgent? Can you Help? JAVED.Javed ShaikhSoftware EngineerMacleods Pharma Ltd. |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-29 : 06:52:37
|
Post the Create Function statement you usedMadhivananFailing to plan is Planning to fail |
|
|
jawu
Starting Member
7 Posts |
Posted - 2005-08-29 : 07:15:12
|
Hi, MadhivananThe Function is:USE pubsGOCREATE FUNCTION SalesByStore (@storeid varchar(30))RETURNS TABLEASRETURN (SELECT title, qty FROM sales s, titles t where t.title_id = s.title_id)Javed ShaikhSoftware EngineerMacleods Pharma Ltd. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-29 : 07:19:29
|
There is nothing wrong with that functionAfter you created that Function in Query Analyser, run thisSelect * from SalesByStore(1)and see what you getMadhivananFailing to plan is Planning to fail |
|
|
jawu
Starting Member
7 Posts |
Posted - 2005-08-29 : 07:26:20
|
but why I m getting the Error when I am trying to Create it. I am able to create the Procedure but not the function. I am very confused now. is there any setting or option or permission or anything else I am missing out.Javed ShaikhSoftware EngineerMacleods Pharma Ltd. |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-08-30 : 09:27:46
|
Maybe this will fix it?USE pubsGOCREATE FUNCTION dbo.SalesByStore (@storeid varchar(30))RETURNS TABLEASRETURN (SELECT title, qtyFROM sales s, titles twhere t.title_id = s.title_id)Help us help YOU!Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2005-08-30 : 10:36:58
|
What compatibility level are you at? Functions requires 80. |
|
|
robg69
Starting Member
41 Posts |
Posted - 2005-09-12 : 12:59:58
|
Oh yea, duh. What LarsG said. Change your compatibility level. |
|
|
|
|
|