Click here to Skip to main content
14,928,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
I am Trying this query but not perform..

INSERT INTO student,address(student.c_name,address.city) values ('moin','nadiad')

In this query student and address are table and 'moin','nadiad' are column data..
Posted
Updated 19-Dec-13 18:21pm
v2

impossible !!!
can not insert values in two table at a time..
better you try double insert query..
   
You can't use INSERT against two tables in one statement.
I would suggest to use transaction here. For example :

SQL
SET XACT_ABORT ON
BEGIN TRANSACTION

INSERT INTO [A](...) VALUES(...);
INSERT INTO [B](...) VALUES(...);

COMMIT TRANSACTION
SET XACT_ABORT OFF
   
Why do you need such type of query. You can perform this by simple using this:-

Insert into student (c_name) values ('moin')

Insert into address (city) values ('nadiad')

Hope, this will helps you...
   
Comments
moin raza khan 20-Dec-13 6:42am
   
Thanks for suggestion But
This question Ask me in Interview...
and interviewer says this question is correct..
at that time i give above solution at that time
and i rejected..
Jain Nishant 22-Dec-13 23:32pm
   
Gud... keep it up...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month



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