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 |
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-03-17 : 10:00:33
|
| I have created a user defined function (basic calculations for testing) inside my database. A lot of the examples I have looked at include calling the functions from within the FROM statement. I am trying to call it from the SELECT statement but nothing is working so far.I am using SQL 2008 Express, and making sure I selected the correct database, tried Cost(), dbo.Cost(), Test.Cost(), Test.dbo.Cost().The function can be seen inside the database programmability folder in the object explorer, but I can't figure out how to call it. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 10:02:54
|
| is it a scalar valued function or table valued?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-03-17 : 10:05:29
|
| I believe it's scalar. I pass in 6 values right now to test. In the end it will take 15 values. It only returns 1 integer value. All parameters passed in are integers.It doesn't use any tables/queries/functions, just the values passed in. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 10:08:02
|
| ok then you need to execute it likeSELECT schema.functionname(paramvalue1,paramvalue2,...,paramvalue6)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-03-17 : 10:17:25
|
| SELECT dbo.Cost('1', 2, 'Lumbago')- LumbagoIf the facts don't fit the theory, change the facts. Albert Einstein |
 |
|
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-03-17 : 10:17:52
|
| schema.Cost() doesn't work - Incorrect syntax near keyword schema.the only thing like schema that shows up are schema_id and schema_name.Edit - Got it working after a little bit, somebody's been renaming databases for backups and renamed the original one. Sorry for the confusion guys... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 10:23:48
|
quote: Originally posted by detlion1643 schema.Cost() doesn't work - Incorrect syntax near keyword schema.the only thing like schema that shows up are schema_id and schema_name.Edit - Got it working after a little bit, somebody's been renaming databases for backups and renamed the original one. Sorry for the confusion guys...
schema means not word schema but put your actual schema name there anyways glad that you sorted it out------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|