Skip to content
Advertisement

Pass a table variable using table type into a stored procedure?

I have a table employee with around 1000 entries, I have to create a stored procedure which accepts a parameter. The parameter will most likely be of the type which I created ‘AS Table’. Upon passing the table variable into the stored procedure, it should update certain values in specific columns and the changes should reflect in the original Employee table.

I tried the following steps:

The above is for the table type and the table variable

Now, for the stored procedure I tried,

Msg 137, Level 16, State 1, Procedure updateEmpDetails, Line 7 [Batch Start Line 2] Must declare the scalar variable “@UpdateType”

Please help me as to where am I going wrong.

I need to update the Employee Table using a stored procedure that accepts table variable.

If possible please provide me with the correct code for the same.

Advertisement

Answer

You are passing a table type, So you need to join with it as a table instead.

FullCode:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement