Using SQL 2008
So I created a User Defined type:
CREATE TYPE dbo.ServiceType AS TABLE ( [TO_ZONE] varchar(30) NOT NULL, [FROM_ZONE] varchar(30) NOT NULL, [RATE] decimal(14,2) NOT NULL, [SERVICE_TYPE] varchar(255) NOT NULL );
And when I try to use it I get the error "parameter or variable @variableName has an invalid data type"
ALTER PROCEDURE [dbo].[ImportServiceTypeRates] (@ServiceTypes dbo.ServiceType) --I have tried it without the "dbo." as well
Update
So I added "READONLY" to my variable declaration
@ServiceTypes dbo.ServiceType READONLY
And I now get the error "The parameter @Servicetype cannot be declared READONLY because it is not a table-valued parameter" ?WHAT?
I thought the "CREATE TYPE ServiceType as TABLE" was what declared it such???
I also have showing in Types\User-Defined Table Types\dbo.ServiceType
Invalid SQL data type errors occur with SPL int64 data types and Oracle databases. If you have data that is an INTEGER data type in a table in an Oracle database, and you attempt to send or receive data by using an int64 data type in an SPL application, invalid data type errors can occur.
The data type varchar is not one of the supported data types on SQL Server CE.
Because Characters, Numeric, and Float are all valid SQL types. If you are willing to learn SQL and wish to get certified in SQL, have a look at the SQL certification course from Intellipaat.
I know this is an old post but since I encountered the same issue and was able to solve it, thought of sharing it. This is an IntelliSense cache issue and could be solved by pressing ctrl+shift+R (shortcut for Edit -> IntelliSense -> Refresh Local Cache)
You must declare your table-valued parameter as READONLY
.
ALTER PROCEDURE [dbo].[ImportServiceTypeRates] @ServiceTypes dbo.ServiceType READONLY AS --your proc
Even though SQL Server forces your table-valued parameter to be read-only, you must also explicitly declare it so in the stored procedure parameter list.
http://msdn.microsoft.com/en-us/library/bb675163.aspx
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