MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
A high performance database engine using optimized data access for all development environments including Delphi, Visual Studio .NET, Visual Basic, Visual FoxPro. and more. Learn More
  #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 online now
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,694 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 15 h 32 m 3 sec
Reputation Power: 848
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


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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

Web Buyers Guide




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway