473,288 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Create script to insert 200 rows into table

I have to create a script to install a database, and one of the tables
has about 200 rows of static data... I dont want to have to manually
type in 200 insert statements, so is there a better way to do this? I
thought about maybe exporting the data into a CSV file and using some
sort of procedure to insert the records that way... Any advise?

Aug 15 '07 #1
6 10406
I did some research and discovered the lovely BCP utility. With this
utility i was able to export the data into a basic txt file using this
as a template:

bcp "SELECT * FROM pubs..authors" queryout authors.txt -U garth -P pw -
c

However I can find any resources on how I would go about putting the
data into the table...
If anyone could please use the above example, as the export and
provide me with a proper import that would be absolutely wonderful.

Aug 15 '07 #2
I figured out that I can just include a bulk insert statement in my
script to do this::

BULK INSERT tmpStList FROM 'c:\TxtFile2.txt' WITH (FIELDTERMINATOR =
',')

however I can't figure out how to use a tab as the field terminator as
opposed to ,

Aug 15 '07 #3
Well, all I did was change the bcp utility to create a CSV file
instead of the tab seperated file...

But when I try to run the bulk insert statement I get this error:

The BULK INSERT SQL construct or statement is not supported.
Error Message:

Cannont bulk load because the file "C:\scripts\attributes.txt" could
not be opened. Operating system error code 123(The filename,
directory name, or volume lable syntax is incorrect.)

Aug 15 '07 #4
Perhaps you ran the BCP utility locally, then ran BULK INSERT on the
server?

Have you noticed yet that BCP works in both directions, IN as well as
OUT?

Roy Harvey
Beacon Falls, CT

On Wed, 15 Aug 2007 16:30:22 -0000, rhaazy <rh****@gmail.comwrote:
>Well, all I did was change the bcp utility to create a CSV file
instead of the tab seperated file...

But when I try to run the bulk insert statement I get this error:

The BULK INSERT SQL construct or statement is not supported.
Error Message:

Cannont bulk load because the file "C:\scripts\attributes.txt" could
not be opened. Operating system error code 123(The filename,
directory name, or volume lable syntax is incorrect.)
Aug 15 '07 #5
My problem was that I was using the wrong instance of sql server...I
was trying to use sql server express, which doesn't support the bulk
insert. After I changed the instance I had no problem getting it to
work. Thanks for your response though.

Aug 15 '07 #6
SQL Script Builder is a multiple platform database migration tool, it
create a database sql script (or dump file) from any ODBC data source.
Scripts are available in 5 output formats ; MySql, MS SQL, Oracle,
Pervasive and PostgreSQL. The script produced will migrate the
database (multiple tables selection) or only one table. SQL Script
Builder can be used for example to migrate your Access database to
MySql database, or MySql database to MS SQL database and vice
versa.There's no limits, all you need is the ODBC driver for the
database you wish to import from.

More Info: http://www.sqlscriptbuilder.com
Download URL: http://www.sqlscriptbuilder.com/down...ildersetup.exe
Screenshot URL: http://www.sqlscriptbuilder.com/images/Interface.jpg

Best regards,
David

Aug 24 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Arnaud | last post by:
Hi, I have a script which inserts some rows in an InnoDB table. I want to be sure that all the rows are inserted, so i use a mysql transaction ("start transaction", insertions, and "commit"). ...
2
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and...
7
by: Wolfgang Kreuzer | last post by:
Hello all, I have two tables - Projects and ProjectStruct Table Projects contains master records of the projects, ProjectStruct allows to define a project herarchie and contains the fields...
6
by: Christopher Benson-Manica | last post by:
I have some markup like the following: <form> <table> <script> <!-- Write the table markup //--> </script> </table> <form>
1
by: Ling Xiaoyu | last post by:
Hello there. Can anybody help me with Postgresql triggers? what I need is a trigger which update value of field "tables_rows.total_rows" to rows count of table "zzz" if I insert new row in table...
5
by: shelleybobelly | last post by:
Hi, I have a new job. It needs to drop and re-create (by insert) a table every night. The table contains approximately 3,000,000 (and growing) records. The insert is fine, runs in 2 minutes. The...
1
by: Matthias Langbein | last post by:
Hi all, I've got a few lines of javascript which works fine with IE, but I don't know how to adapt the code so it also works on FF: ************************************ // create the table...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
12
by: micky125 | last post by:
Hey guys, another part of program I am stuck at is to create an email storage / reference system. I need the first line to hold the basic info, from to address etc and then a second row to store the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.