I am trying to create a user defined table type in SQL Server 2008 R2 version but unable to create.
Using the following query
create type <table_type_name> as table
(
UserId int,
FirstName varchar(50)
)
It shows the error message "157, Incorrect syntax near keyword AS."
Also I want to mention one thing that in the folder hierarchy of the SQL Server under the Programmability -> Types folder I am not able to see the folder "User Defined Table Type".
Is there any way to fix this problem?
You must specify the name of your user defined table, eg [TypeName} on the query. You must include square brackets if you want to use type as your user defined table name eg [type].
Use the following:
create type [TypeName] as table
(UserId int,
FirstName varchar(50))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With