SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


a problem with sql 2008 statemets


a problem with sql 2008 statemets

Author
Message
nihal124
nihal124
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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?!!
Ken McKelvey
Ken McKelvey
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4035 Visits: 8435

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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search