 |
| SQL Server 2005 General discussion of SQL Server *2005* version only. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 21st, 2007, 11:56 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
trying to run an udf
Hello,
I have and UDF called "Normalizar":
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Normalizar(SqlString AText)
{
return new SqlString(NormalizeStr((String)AText));
}
I am trying to execute it:
select dbo.Normalizar(user);
but next message appears:
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Normalizar", or the name is ambiguous.
Anybody can help? thanx
|
|

July 21st, 2007, 07:14 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
|
|
GRANT EXECUTE ON dbo.Normalizar TO PUBLIC ?
--Jeff Moden
|
|

July 22nd, 2007, 04:50 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, but I tried it:
Cannot find the object 'Normalizar', because it does not exist or you do not have permission.
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Normalizar", or the name is ambiguous.
I tried also to see the function using SQL Server Management Express, but I didn't find it.
|
|

July 22nd, 2007, 05:10 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
My project is an Sql Server 2005 project. I have the default debug script "test.sql", which contains the grant and select commands, and also all the table creates that works fine, and I can locate with the Sql Server Management Express.
My UDF is a C# file: "Normalizar.cs", but it seems the deployment doesn't build the function in the server, or I don't know how to see it.
|
|

July 22nd, 2007, 07:39 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I finally succeded. The problem was that my initial catalog in the project's DB connection was the master database. And I created the assembly in this database, but my test.sql also creates and uses a new database, and cannot find the UDF in this DB.
After changing the connection, I can use my UDF in my own database.
Thanks
|
|

July 22nd, 2007, 07:43 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
But now I have other problem.
My connection:
Data Source=MOSSA-DESA\SQLEXPRESS;Initial Catalog=CDBX;Integrated Security=True
Part of my test.sql code:
USE master;
IF DB_ID (N'CDBX') IS NOT NULL
DROP DATABASE CDBX;
-- Get the SQL Server data path
DECLARE @data_path nvarchar(256);
SET @data_path = (SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1)
FROM master.sys.master_files
WHERE database_id = 1 AND file_id = 1);
-- execute the CREATE DATABASE statement
EXECUTE ('CREATE DATABASE CDBX ON
( NAME = CDBX_dat,
FILENAME = '''+ @data_path + 'CDBX.mdf'',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = CDBX_log,
FILENAME = '''+ @data_path + 'CDBX.ldf'',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )'
);
My new error:
Cannot drop database "CDBX" because it is currently in use.
Database 'CDBX' already exists.
¿¿???
|
|

July 22nd, 2007, 08:04 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Really, it's not very important, because I can drop and re-create all the tables without problem.
|
|

July 22nd, 2007, 11:12 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
|
|
Thanks for the feedback on the UDF problem solution.
--Jeff Moden
|
|
 |