The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> MS SQL Development
|
insert multiple values
Discuss insert multiple values in the MS SQL Development forum on Dev Shed. insert multiple values MS SQL Development forum discussing administration, MS SQL queries, and other MS SQL-related topics. SQL Server is Microsoft's enterprise database engine.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 8th, 2003, 10:31 AM
|
|
Junior Member
|
|
Join Date: Sep 2003
Location: Sweden
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
insert multiple values
How do I write the different values together in the first statement instead of writing it twice like this???
Im writing in T-SQL.
I need to populate the tables in my test database to run it but I dont want to write every entry in new insert statements.
USE Test
INSERT INTO table1 (A, B, C, D,
E, F, G,H)
VALUES ('lala', 'Bob', 'Swanson', 'Brook Ave 541', '274 37', 'USA'
, '002-326565656', 'ps@aol.com')
USE Test
INSERT INTO table1 (A, B, C, D,
E, F, G,H)
VALUES ('blabla', 'Anna', 'Asey', 'Brook str 19', '274 37', 'Skivarp'
, '04-12565656', 'aa@aol.com')
|

October 8th, 2003, 11:15 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
you could upload the data into a holding table
here's what i do
if the data is in comma- or tab- delimited format, or even fixed-length format (all fields start in the same column position), then i will either open it in excel, or paste into excel and use Data > Text as Columns, then save it as a spreadsheet, then DTS the spreadsheet into SQL Server
otherwise i use search and replace in a text editor to slap the INSERT syntax around my values and run the whole series of INSERT statements in one execution in Query Analyzer
the deciding factor, whether to go the text edit or excel/DTS route, depends on whether there are more than a couple thousand rows to do this way (search & replace is error-prone)
rudy
http://r937.com/
|

October 8th, 2003, 03:38 PM
|
 |
Junior Member
|
|
Join Date: Oct 2003
Location: Spokane Washington
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
If you just want to populate a table with dummy data, and its worth your time, you might try running the insert statement in a loop, and using the rand function to randomly generate your data. I don't think I'd go through all of this unless I needed thousands of dummy entries though 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|