March 11, 2011 at 8:39 am
i want to insert a row in two tables at the same time bu it didn't work !!
here's the code
---------------------------------
USE [RFID]
GO
/****** Object: StoredProcedure [dbo].[Insert_Login_Role] Script Date: 03/12/2011 01:08:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Insert_Login_Role]
@Login_Name nvarchar(50),
@First_Name nvarchar(50),
@Last_name nvarchar(50),
@user_Password nvarchar(50),
--@Login_date date,
@Gender nchar(10),
--@Birth_year date,
@Role_Name nvarchar(50)
-- @Role_ID int
--@Role_ID2 int
AS
BEGIN
set nocount on
declare @Role_ID int
INSERT INTO Login
(Login_Name,First_Name, Last_name,user_Password,
Login_date,Gender,Birth_year)
VALUES
(@Login_Name
,@First_Name ,@Last_name ,@user_Password ,'07-05-1990 ',@Gender ,'07-04-1990 ')
SELECT @Role_ID = (SELECT max(Role_ID) FROM Login)
INSERT INTO Role
(Role_Name,Role_ID)
values(@Role_Name,@Role_ID)
set nocount off
END
---------------------------------------
could any one help me?!!
March 11, 2011 at 9:09 am
SET ANSI_NULLS, QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE dbo.Insert_Login_Role
@Login_Name nvarchar(50),
@First_Name nvarchar(50),
@Last_name nvarchar(50),
@user_Password nvarchar(50),
--@Login_date date,
@Gender nchar(10),
--@Birth_year date,
@Role_Name nvarchar(50)
-- @Role_ID int
--@Role_ID2 int
AS
SET NOCOUNT ON
INSERT INTO [Login] (Login_Name, First_Name, Last_name, user_Password, Login_date, Gender, Birth_year)
OUTPUT @Role_Name, inserted.Role_ID INTO [Role](Role_Name, Role_ID)
VALUES(@Login_Name, @First_Name, @Last_name, @user_Password, '07-05-1990 ', @Gender , '07-04-1990 ')
GO
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply