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
 Multiple insert in different table with bulkupload

Author  Topic 

meetmanthan
Starting Member

2 Posts

Posted - 2009-08-11 : 09:18:37
Hi.
I am having very strang situation. In which I need to use bulk upload. for which I use XML bulk upload insertion. Now the problem is that I need to make an entry in different table for every record. For example:

In my record list I am having categoryName, description, TransctionId and etc. which I am passing in XML file format. Now I need to insert categoryName in Category table and After that I need to retrieve that ID from Category table. After that When I am saving records in my transction table, I need to save it with CategoryID,description,TransctionId and etc in it. Every record have different category. I need to do it in single insert. So how can I do that??

meetmanthan
Starting Member

2 Posts

Posted - 2009-08-12 : 05:12:37
I want to do like this:

use TestDatabase
declare @DeptId as int
INSERT INTO [TestDatabase].[dbo].[Users]
([UserName]
,[DepartmentId])
VALUES
('Manthan',[TestDatabase].[dbo].returnDeptID ('DOTNET'))
GO
where [TestDatabase].[dbo].returnDeptID ('DOTNET') is my storeprocedure which is describe as below:
create procedure [dbo].[returnDeptID]
@departmentName as varchar(50),
@deptID as int output
as
begin
insert into dbo.Departments (DepartmentName) values(@DepartmentName)
select @deptID = DepartmentID from inserted
End
Go to Top of Page
   

- Advertisement -