iam trying insert rows into a sql table in java. i need to insert into a table simulateneously with 2 different data.here am using 2 queries to insert data to dbo.Company obtained from some manipulations into a single table
statement1.executeUpdate("insert into
dbo.Company(CName,DateTimeCreated,DateTimeLastModified)
values('"+cname[i]+"','"+ts+"','"+ts+"')");
statement3.executeUpdate("insert into
dbo.Company(CName,DateTimeCreated,DateTimeLastModified)
values('"+EMpname[i]+"' ,'"+ts+"','"+ts+"')");
i need to insert cname[i] and EMpname[i] into dbo.Company using single query… please help to write this query.
Multiple
VALUESsupported since 2008. If your server version is lower useUNION: http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/