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

What is rtm version in sql server?

698


How do I find the sql server instance name?

720


What is dirty page?

728


Explain indexes disadvantages?

752


What is schemabinding a view?

696






What does nvl stand for?

710


Difference between 2NF &3NF ?

843


Explain what stored procedure sp_replcounters is used for? : sql server replication

1236


What are triggers? How do you invoke a trigger on demand?

974


Define views.

756


What are the authentication modes in sql server? How can it be changed?

791


What do you mean by collation recursive stored procedure?

784


Can sql servers linked to other servers?

732


What are the different types of columns types constraints in the sql server?

736


What is the impact on other user sessions when creating indexes?

713