how to insert the values in 5 table at a time Using any
single statement ?

Answer Posted / vishnu

It is not possible to insert multiple rows with a single
insert statement. If you want to insert multiple rows, one
have to write multiple insert statements considering that
you are working SQL server 2005 or it's below version.

But SQL Server 2008 allows to insert multiple rows with a
single insert statement.

As for example,
In sql server 2005, if we need to insert multiple row, we
used to do something like this.
CREATE TABLE [State] (
[StateID] int,
[StateName] VARCHAR(20)
)
GO

INSERT INTO State
VALUES (1, 'Gujarat')

INSERT INTO State
VALUES (2, 'Dehli')

INSERT INTO State
VALUES (3, 'Bihar')

But with SQL Server 2008 we can combine all the three insert
statement in single insert statement. See below:
CREATE TABLE [State] (
[StateID] int,
[StateName] VARCHAR(20)
)
GO

INSERT INTO State
VALUES (1, 'Gujarat'),
(2, 'Dehli'),
(3, 'Bihar')

Hope this helps...

Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is natural join and equi join same?

541


what number files will a information contain in SQL Server? How many forms of information files exist in SQL Server? How many of those files can exist for a single database?

543


What are four major operators that can be used to combine conditions on a where clause?

605


How to create a simple stored procedure in ms sql server?

529


Can I use sql azure as a backup with log shipping or database mirroring?

136






List the different types of collation sensitivities in sql server?

545


What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration

602


How do I find my localdb version?

504


Write a SQL queries on Self Join and Inner Join.

623


What is the minimum and maximum number of partitions required for a measure group? : sql server analysis services, ssas

609


How do I install only the client tools of sql server 2000?

560


What are views used for?

626


How to write a query with a full outer join in ms sql server?

570


When would you use a before or after trigger?

500


What is the difference between left and right outer join?

559