Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
good evening everyone,


I have problem inserting record Header Table and Detail Table.
my Header Table Is given Below

SQL
CREATE TABLE [dbo].[TransactionHeader](
    [TransactionKey] [int] IDENTITY(1,1) NOT NULL,
    [TransactionType] [int] NULL,
    [IntExternalFlag] [int] NULL,
    [TransactionDate] [datetime] NULL,
 CONSTRAINT [PK_TransactionHeader] PRIMARY KEY CLUSTERED
(
    [TransactionKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]



and Detail Table is Given Below.


SQL
CREATE TABLE [dbo].[TransactionDetail](
    [DetailKey] [int] IDENTITY(1,1) NOT NULL,
    [TransactionKey] [int] NOT NULL,
    [AssetID] [int] NULL,
    [LocationID] [int] NULL,
    [EmployeeID] [int] NULL,
    [SupplierID] [int] NULL,
    [IssuedReceivedDate] [datetime] NULL,
    [TransactionDate] [datetime] NULL,
 CONSTRAINT [PK_TransactionDetail] PRIMARY KEY CLUSTERED
(
    [DetailKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TransactionDetail]  WITH CHECK ADD  CONSTRAINT [FK_TransactionDetail_TransactionHeader] FOREIGN KEY([TransactionKey])
REFERENCES [dbo].[TransactionHeader] ([TransactionKey])
GO




I want To Create one Stored procedure which is insert the one Record into Header and Multiple Record In Details Table.
My transactionKey is automatically generated by identity specification property of table.

so please help me how can i create procedure ....................
please give me any example.

Thanks
Posted

1 solution

Many ways....

Pick couple of them

Use OPENXML[^] or XQuery[^] or SQLXML[^]

Insert Data into SQL 2000 Using OpenXML & ADO.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900