Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sandip.mondal
Starting Member
1 Post |
Posted - 2011-12-16 : 03:56:45
|
| Please define how to insert data in sql serversandip kumar mondal |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2011-12-16 : 04:21:38
|
| insert into <table>select from <table>or from a flat file, use bcp or bulk insertyou can also use osql as well as ssis, dts (if pre-2005) as well as other third party methods.Now, what exactly were you after? |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2011-12-16 : 06:25:49
|
Or better still (it protects you from column ordinal changes / development )INSERT INTO <table> (COLUMN LIST)SELECT (COLUMN LIST) FROM <...> Or if you want to insert static valuesINSERT INTO <table> (COLUMN LIST)VALES (val1,val2,val3....valn),(val1,val2,val3....valn).... Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-16 : 06:29:13
|
quote: Originally posted by Transact Charlie Or better still (it protects you from column ordinal changes / development )INSERT INTO <table> (COLUMN LIST)SELECT (COLUMN LIST) FROM <...> Or if you want to insert static valuesINSERT INTO <table> (COLUMN LIST)VALES (val1,val2,val3....valn),(val1,val2,val3....valn).... Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
You can use the above format from sql 2008 onwardsfor below version use modified suggestion belowINSERT INTO <table> (COLUMN LIST)SELECT val1,val2,val3....valn UNION ALLSELECT val1,val2,val3....valn.... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2011-12-16 : 06:41:19
|
| cheers!Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|
|