Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

a problem with sql 2008 statemets Expand / Collapse
Author
Message
Posted Friday, March 11, 2011 8:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 11, 2011 12:52 PM
Points: 1, Visits: 2
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?!!
Post #1076937
Posted Friday, March 11, 2011 9:09 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 9:03 AM
Points: 848, Visits: 5,504
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

Post #1076974
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse