MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 8th, 2003, 10:31 AM
buggirl buggirl is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sweden
Posts: 6 buggirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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')

Reply With Quote
  #2  
Old October 8th, 2003, 11:15 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,371 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 32 m 18 sec
Reputation Power: 4140
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/

Reply With Quote
  #3  
Old October 8th, 2003, 03:38 PM
Zippygoose's Avatar
Zippygoose Zippygoose is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Spokane Washington
Posts: 7 Zippygoose User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Zippygoose
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > insert multiple values

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap