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 |
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-11 : 21:35:31
|
In SQL 2008, I'm logged in to SSMS as admin, to my server running locally on my machine. When I create tables and so on, they all have the schema "dbo" by default.I've created a user-defined function:CREATE function [dbo].[fnConcatUpcomingEvents] (@CourseId int) ...which was created ok. But when I try to access it from a query, it get underlined with the message ".. is not a recognised built-in function name": When I modify the function, there also suddenly the name is underlined with the error "invalid object name". However there was no such message when it was created. What does this strangeness mean? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-11 : 23:42:39
|
whats the type of udf? is it scalar or table valued? How you're calling it? Also make sure you've selected the correct database while trying to execute the function. It would be better if you can put a USE[DBName] on top to indicate that it points to correct db.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-12 : 00:26:48
|
Hi Visakh, thanks once again. It is a scalar function. Sorry for the big images (you mentioned before you can't view external images) but here's screenshots of the CREATE, followed by the ALTER when I modify it directly after creating it.Create it: Select Modify: Then the error appears in the ALTER statement. Weird! If we can work out why this is happening, it might make the other part clear.As you can see, the USE is at the top of the ALTER code, but it still complains. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-12 : 00:35:04
|
sorry I cant see images again Anyways if its scalar function you should be calling it asSELECT dbo.[fnConcatUpcomingEvents] (parametervalue)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-12 : 01:41:51
|
Cool, sorry about the images.I do call it like that. It just occurred to me, perhaps I'm not CREATE-ing it properly. When I start a new function (under the Scalar functions area) it shows a template with the CREATE statement like this:CREATE FUNCTION <Scalar_Function_Name, sysname, FunctionName> However I created it simply like this:CREATE function ConcatDivTagsByCodeIdWould that make a difference? Should I be supplying the other parameters sysname and FunctionName? |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-12 : 10:18:04
|
Now I can see the images. DOnt worry seeing the redline across function name. It sometimes happens when it didnt pick up the recent changes in metedata. However if you try to run the code, it will still run fine.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|