Environment: Win7 and SQL server 2008 R@
Tools: SQL management tool 2008 R2
T-SQL code - works fine- :
DECLARE @return_value int, @new_id char(9) EXEC @return_value = [dbo].[proc_gen_id] @new_id = @new_id OUTPUT SELECT @new_id as N'@new_id'
Outcome - for example-: 433194976 or 907959111
T-SQL code
CREATE TABLE employees ( id char(9), employee_number number(10) not null, employee_name varchar2(50) not null, salary number(6), CONSTRAINT employees_pk PRIMARY KEY (employee_number) ); INSERT INTO employees (employee_number, employee_name, salary) VALUES (1001, 'Sally Johnson', 32000); INSERT INTO employees (employee_number, employee_name, salary) VALUES (1002, 'Will Smith', 38000); INSERT INTO employees (employee_number, employee_name, salary) VALUES (1003, 'Jessica simpson', 32000); INSERT INTO employees (employee_number, employee_name, salary) VALUES (1004, 'Michael Lira', 65000);
Problem:
How I would update an id column, which is generated/called by the stored procedure
My code
DECLARE @return_value int, @new_id char(9) EXEC @return_value = [dbo].[proc_gen_id] @new_id = @new_id OUTPUT SELECT @new_id as N'@new_id' UPDATE Employee Set id=@new_id
Before
('null',1001, 'Sally Johnson', 32000);
('null',1002, 'Will Smith', 38000);
('null',1003, 'Jessica simpson', 32000);
('null',1004, 'Michael Lira', 65000);
After:Expected results
('433194976',1001, 'Sally Johnson', 32000);
('907959111',1002, 'Will Smith', 38000);
('819753931',1003, 'Jessica simpson', 32000);
('000753931',1004, 'Michael Lira', 65000);
Please help