4 replies
by joseph moore
Ok, I did this in about 5 minutes (and that counted getting Excel to co-operate correctly!!)
First, let's say your database is called BOOKS, and it is in table AUTHORS you want to create your 48000 records with these 1B, 2B and 6B fields.
Ok. Make a blank spreadsheet. In Column A Row 1 put in:
insert into AUTHORS (NUMBERCOL) values
In Column B, Row1, put in:
(1B0001
And in Column C, Row1 put in:
)
Now, copy/paste Column A Row1 cell (the Insert command) and paste them for as many thousands of records you need for the 1B line. Next, do the copy/paste for Column B Row1 cell but do it as a Fill Series so you get (1B0002 in Row2, (1B0003 in Row3, etc.
And lastly, copy/paste Column C Row1, the closed paranthesis, into every row.
Then, just SAVE AS the whole thing as a UNICODE .TXT file. For example, save this first one as 1B.TXT
Ok, now open 1B.TXT and it will look like this:
insert into AUTHORS (NUMBERCOL) values (1B0001 )
insert into AUTHORS (NUMBERCOL) values (1B0002 )
insert into AUTHORS (NUMBERCOL) values (1B0003 )
insert into AUTHORS (NUMBERCOL) values (1B0004 )
insert into AUTHORS (NUMBERCOL) values (1B0005 )
insert into AUTHORS (NUMBERCOL) values (1B0006 )
etc.
All you then need to do in Notepad is do a Find/Replace, where you searc for " )" and replace it with just ")" (without the quotation marks!)
Doing that, you get:
insert into AUTHORS (NUMBERCOL) values (1B0001)
insert into AUTHORS (NUMBERCOL) values (1B0002)
insert into AUTHORS (NUMBERCOL) values (1B0003)
insert into AUTHORS (NUMBERCOL) values (1B0004)
insert into AUTHORS (NUMBERCOL) values (1B0005)
insert into AUTHORS (NUMBERCOL) values (1B0006)
etc.
There you go.
by joseph moore
Now just open Query Analyzier, select your database in the drop-down list, then File -> Open and select the 1B.TXT file.
After that, click the green arrow button to run this file!
It will create records in the AUTHORS table, where the NUMBERCOL field = the 1B#### entry for each record. If you have 10,000 1B records in the 1B.TXT file, this will make 10,000 records in your SQL Server database with the correct 1B info per record!
hope this helps
by shield509
by shield509
This discussion is closed to new replies.
Trending IT Employment posts
Sort by Trending