Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 creating procedure for other insertion

Author  Topic 

Reg
Starting Member

7 Posts

Posted - 2007-11-20 : 00:57:14
Hi everyone,

i am self-learner for sql server 2005.

can anybody help me,

currently, i have two tables..called
employee
(eg. empid varchar(10),languageid(10),quaid(10))

unprocesstable
(eg.unid uniqueidentifier, unpname varchar(50),unptablename varchar(50),empid (10) )

how to create another store procedure for other insertion?

eg.. whatever other language is inserted into employee by user which is not in the "language" table ,

it will inserted into (table "unprocesstable") under (column "unpname")

thank you so much!



Rg

georgev
Posting Yak Master

122 Posts

Posted - 2007-11-20 : 06:56:07
A nice big, untested, stab in the dark :D
[CODE]
CREATE PROCEDURE storedProcedureName
ON employee
FOR INSERT, UPDATE
AS
INSERT INTO unprocesstable(empID)
SELECT i.empID
FROM languages l
LEFT
JOIN inserted i
ON i.languageID = l.languageID
WHERE l.languageID IS NULL
GO
[/CODE]


George
<3Engaged!
Go to Top of Page

Reg
Starting Member

7 Posts

Posted - 2007-11-29 : 21:09:10
Thank you George.
Having another proplem...

I have created two insertion procedure for employee and employeedetails.

But I would like to combine as one procedure...how can i do that?

Employee (eg...

ALTER PROCEDURE [dbo].[sp_TBLEmployee_Ins]
@EmpID VARCHAR (12),@LagIDFirst VARCHAR(10),@QuaID VARCHAR(10),
@AddCombID VARCHAR(10)
AS
INSERT INTO TBLEmployee(EmpID,LagIDFirst,QuaID,AddCombID)
Values (@EmpID,@LagIDFirst,@QuaID,@AddCombID)



Employeedetails (eg...

ALTER PROCEDURE [dbo].[sp_TBLEmpDetails_Ins]
@EmpID VARCHAR(12), @MajorID VARCHAR(10),@SchID VARCHAR(10),
@EmpPrimarySkill VARCHAR(100)

AS
INSERT INTO TBLEmpDetails(EmpID,MajorID,SchID,EmpPrimarySkill)
Values (@EmpID,@MajorID,@SchID,@EmpPrimarySkill)





Rg
Go to Top of Page

avmreddy17
Posting Yak Master

180 Posts

Posted - 2007-11-29 : 21:19:01
I guess georgev meant to

CREATE TRIGGER <TriggerName>

Venu
Go to Top of Page

avmreddy17
Posting Yak Master

180 Posts

Posted - 2007-11-29 : 21:21:41
ALTER PROCEDURE [dbo].[sp_TBLEmployee_Ins]
@EmpID VARCHAR (12),
@LagIDFirst VARCHAR(10),
@QuaID VARCHAR(10),
@AddCombID VARCHAR(10),
@MajorID VARCHAR(10),
@SchID VARCHAR(10),
@EmpPrimarySkill VARCHAR(100)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO TBLEmployee(EmpID,LagIDFirst,QuaID,AddCombID)
Values (@EmpID,@LagIDFirst,@QuaID,@AddCombID)

INSERT INTO TBLEmpDetails(EmpID,MajorID,SchID,EmpPrimarySkill)
Values (@EmpID,@MajorID,@SchID,@EmpPrimarySkill)
END
Go to Top of Page

Reg
Starting Member

7 Posts

Posted - 2007-11-30 : 03:40:43
Thank you very much Avmreddy17 !

But I also have the sp_empDetails_Upd
will it works both for inserting and updating for empDetails table?

thanks for your helps ye!

Rg
Go to Top of Page
   

- Advertisement -