I am writing a store procedure in T-SQL which inserts a row to the table, based on parameters
@UserName ,@CompanyName ,@RestName,@Desc
INSERT INTO Orders(UserId,CompanyId,RestId)
SELECT UserNames.Id,CompanyNames.Id,RestNames.Id FROM UserNames,CompanyNames,RestNames
WHERE
UserNames.Name = @UserName AND
CompanyNames.Name = @CompanyName AND
RestNames.Name = @RestName
Besides the insert to the 3 columns above,I also want to insert the @Desc value.
I tried :
INSERT INTO Orders(UserId,CompanyId,RestId,Desc)
VALUES(
(SELECT UserNames.Id,CompanyNames.Id,RestNames.Id FROM UserNames,CompanyNames,RestNames
WHERE
UserNames.Name = @UserName AND
CompanyNames.Name = @CompanyName AND
RestNames.Name = @RestName),@Desc)
Only one expression can be specified in the select list when the subquery is not introduced with EXISTSt- It doesn`t work giving the following error: