I'm new to table valued parameters -- admittedly a little late but better late than never.
I'm trying to insert some "new" employees into my Employees table. However, if the new employee has some predetermined skills, I want to enter them during the insert for the employee. The curve ball here is that the new employee may not have any predetermined skills in which case the table-valued parameter would have to be null.
Can I actually set it to null? When I tried it, it gave me an error where I'd usually would "= null". So the idea is something like this:
CREATE PROCEDURE spNewEmployee
@Skills SkillsTableType READONLY = null
DECLARE @EmployeeID int
INSERT INTO Employees
SET @EmployeeID = SCOPE_IDENTITY()
-- This is where I'd like to check to see if @Skills is NULL
-- And if not, I'd like to make entries into EmployeeSkills table using the @EmployeeID I just got and the data coming from @Skills
The @Skills parameter would simply have the SkillID and SkillLevelID.
Could someone tell me if a table-valued parameter can be null? If so, how do I actually use it in this instance where I'm getting the EmployeeID from SCOPE_IDENTITY and using it w/ the table-valued parameter received?
Not to mention, if @Skills is null, then I only insert the new employee and not worry about adding the skills to his/her profile.