I have an array of data from a console app I've developed that I need to transfer into a SQL database. As SQL injections are volatile, I decided to try passing it through a stored procedure via table-valued parameter. I created the table type with no issues and it is listed under 'User-Defined Table Types' folder. The issue I am having is when I try to create my stored procedure, I receive this error:
Msg 2715, Level 16, State 3, Procedure sp_IsertBackupData, Line 2 [Batch Start Line 0] Column, parameter, or variable #1: Cannot find data type VeeamTableType. Parameter or variable '@VeeamTableType' has an invalid data type.
Does anyone have any insight on what could be the issue here?
I have already tried refreshing the local cache.
CREATE PROCEDURE sp_IsertBackupData
@VeeamTableType VeeamTableType READONLY
AS
BEGIN
DECLARE @q varchar(1000)
SET @q= 'SELECT * FROM' + @VeeamTableType
INSERT INTO ASManagement.dbo.VeeamBackupResults
(
Id,
Server,
BackupLogFileName,
BackupLogFileSize,
CreatedOn
)
EXEC (@q)
END
SELECT * FROM ASManagement.VeeamBackupResults
CREATE TYPE VeeamBackupResults.VeeamTableType as TABLE
(
Id int primary key,
Server varchar(500) null,
BackupLogFileName varchar (500) null,
BackupLogFileSize float null,
CreatedOn datetime null
)