I'm trying to do a simple insert into a table that collects feedback and tracks who left the feedback. I have two tables:
FeedbackID int (4)
Feedback varchar (500)
UserNameID int (4)
UserCapitalHealthIdentity varchar (30)
I would like to insert the Feedback and the UserNameID, with the UserNameID pulled from the Users table based on the UserCapitalHealthIdentity.
I'm not great at T-SQL, but thought I would give it a shot:
INSERT INTO Feedback(Feedback, UserName)
VALUES ('this is test feedback',
(SELECT UserNameID where UserCapitalHealthIdentity = 'ch\JensGerbitz')
Got the following error:
Server: Msg 1046, Level 15, State 1, Line 3
Subqueries are not allowed in this context. Only scalar expressions are allowed.