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
What is the impact on other user sessions when creating indexes?
What is used to replicate sessions between instances in coldfusion clusters?
What is sql server management studio? : sql server management studio
how many bits ip address consist of? : Sql server database administration
what is blocking? : Sql server database administration
When would you use it?
What are the difficulties faced in cube development? : sql server analysis services, ssas
How to verify the port number of the sql server?
what are different types of backups available in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration
how to avoid cursors? : Sql server database administration
Why we use the openxml clause?
What is logon trigger?
Does sql server 2000 full-text search support clustering?
How to write an inner join with the where clause in ms sql server?
Tell me what is difference between view and materialized view?