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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 error creating table UDF in sql express

Author  Topic 

smh
Yak Posting Veteran

94 Posts

Posted - 2009-11-07 : 19:44:05
I followed the sample from a previous question to create a UDF table in sql server 2008 Express:

USE fioes
GO

-- Create the data type
CREATE TYPE dbo.lotUDF AS TABLE
(

ID int
)
GO


CREATE PROC usptesttab @tabUDT dbo.lotUDF READONLY
AS

SELECT ID
FROM @tabUDT

GO

when I type in the proc, even before creating it, I get the error that @tabUDT cannot be declared readonly because it is not a table-valued parameter.

also if I type:

select ID from dbo.lotUDf

I get an error saying
Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.lotUDf'.

However, I can see the table and the field under the userdefined table types section in the sql manager.

I do not have a primary key because I did not know if the UDF accepted identity columns if that could be the problem..

Also, I am running as administrator and all the users accessing the stored procdure with the UDF will have all rights to use the database, so I don't see how that would be the problem.

I have not found any similar problem on the web so I must be doing something wrong. Appreciate any help

sshelper
Posting Yak Master

216 Posts

Posted - 2009-11-18 : 00:07:57
First, you cannot do a SELECT ID FROM dbo.lotUDF because lotUDF is really not a table but just a user-defined table type. Second, try removing the dbo in your user-defined table type and just use lotUDF everywhere. Try following the sample in the following link:

http://www.sql-server-helper.com/sql-server-2008/table-valued-parameters.aspx

Regards,
SQL Server Helper
http://www.sql-server-helper.com/sql-server-2008/index.aspx
Go to Top of Page
   

- Advertisement -