Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
CREATE FUNCTION cleanurl(@urltoclean nvarchar(50))RETURNS nvarchar(50) AS BEGIN declare @cleanurl nvarchar(50)select @cleanurl=replace(replace(@urltoclean,' ','-'),'#','')return @cleanurlEND
which executed successfullybut when i do select * from products where cleanurl(title) = 'this is a test' i get 'cleanurl' is not a recognized function name.
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2011-04-01 : 07:03:35
For UDF's you have to explicitly specify the schema name even if it is dbo.
select * from products where dbo.cleanurl(title) = 'this is a test'
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2011-04-01 : 09:05:17
Also, you dont need a function. You can directly useselect * from products where replace(replace(title,' ','-'),'#','') = 'this is a test'MadhivananFailing to plan is Planning to fail
esthera
Master Smack Fu Yak Hacker
1410 Posts
Posted - 2011-04-02 : 13:02:34
i see if i use the username it works though I will have to change in the code if i move servers (which I may do )i want it in a function as I want to use it in a nubmber of places and be able to add more replaces to the function without having to change everywhere