Can this query be written with out using variable?
Basically what I need is an ID of some thing from some table for inserting a new record. Right now I'm doing it by storing that ID in 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);
INSERT INTO [ITD640_B].[dbo].[employee]
([employee_no]
,[employee_fname]
,[employee_lname]
,[store_no])
SELECT
123456
,'YourFirstName'
,'YourLastName'
,[store_no]
FROM
store
WHERE
store_name = 'Rocky Mountain Produce';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With