Is it possible to write this query using a variable?
Basically, I need the identifier of some thing from some table to insert a new record. Now I am doing this by storing this identifier in a variable and then using it.
DECLARE @store_num char(4);
SELECT @store_num = [store_no] FROM store WHERE (store_name = 'Rocky Mountain Produce');
INSERT INTO [ITD640_B].[dbo].[employee]
([employee_no]
,[employee_fname]
,[employee_lname]
,[store_no])
VALUES
(123456
,'YourFirstName'
,'YourLastName'
,@store_num);
claws source
share