Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi my name is faiz I have been facing a problem in my codes please help me
Problem is I have two tables and fields are
Table1

1          2     3                          4         
Id(guid)   Name  serial No(guid or string)  Price

Table2
1          2     3             4
Id(guid)   name  serial No     location


When i insert data in table1 so I want the same serial number would go in table2 serial number.
How will be the SQL Query and how i will implement in our code .please help me
Posted
Updated 20-Jan-12 21:57pm
v2

This[^] should help you
 
Share this answer
 
Write stored procedure as below

SQL
CREATE PROCEDURE sp_InsertSerialNumber
(
   @Id UniqueIdentifier ,
   @Name NVARCHAR(255),
   @SerialNo NVARCHAR(255),
   @Price BigInt ,
   @Location NVARCHAR(255)
)
AS
BEGIN
 INSERT INTO Table1
 SELECT @Id,@Name,@SerialNo,@Price

 INSERT INTO Table2
 SELECT @Id,@Name, @SerialNo,@Location
END


Hope this help
--Rahul
 
Share this answer
 
Comments
faizyab 2009 21-Jan-12 14:59pm    
Thank you sir .if i don't use store procedure so how i can do it ?
RDBurmon 23-Jan-12 1:06am    
Ok Can you post little bit portion of your C# Code so that I will debug and update that code as well.

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