Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


how to write text file's data to MSDE

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,41775
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> how to write text file's data to MSDE
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 how to write text file's data to MSDE - 1/6/2007 8:34:46 PM   
  lividace

 

Posts: 5
Score: 0
Joined: 1/6/2007
Status: offline
hi all,

How to transfer all the data in the text file to the MSDE/SQL server using vbscript?
I couldnt found any example for it......

< Message edited by lividace -- 1/6/2007 8:43:41 PM >
 
 
Post #: 1
 
 RE: how to write text file's data to MSDE - 1/8/2007 12:56:16 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
How do you want it stored? As text? As a binary blob? How large are the files? Will you need to use the information from the texrt file in queries?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to lividace)
 
 
Post #: 2
 
 RE: how to write text file's data to MSDE - 1/9/2007 12:11:26 AM   
  lividace

 

Posts: 5
Score: 0
Joined: 1/6/2007
Status: offline
For Example, i have data with column product ID, product description, price, qty...etc.  in the text file. So, how do i transfer all these data into MSDE/SQL server which also contain product ID, product description, price, qty...etc with using vbscript??

(in reply to lividace)
 
 
Post #: 3
 
 RE: how to write text file's data to MSDE - 1/9/2007 12:56:29 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Is the data in the text file delimited in some way?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to lividace)
 
 
Post #: 4
 
 RE: how to write text file's data to MSDE - 1/11/2007 1:29:35 AM   
  lividace

 

Posts: 5
Score: 0
Joined: 1/6/2007
Status: offline
ok... make it simple

job_id          job_desc
1                  New Hire - Job not specified
2                  Chief Executive Officer
3                  Business Operations Manager
4                  Chief Financial Officier
5                  Publisher 
6                  Managing Editor
7                  Marketing Manager
8                  Public Relations Manager
9                  Acquisitions Manager
10                Productions Manager
11                Operations Manager
12                Editor
13                Sales Representative
14                Designer
 
how does i pass all the data above from the text file into MSDE with vbscript??
The data may increase by time to time.....

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: how to write text file's data to MSDE - 1/11/2007 2:29:33 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
To be honest with you, MSDE and MS-SQL both provide facilities to pull data into the DB from a text file. I would suggest this as your best route. Failing that you could open the text file in VBS and read each line, split the line, then insert the data into the table. If you want to go the VBS route, here are some search terms that you can use to get you started findinge examples on this forum:

FileSystemObject
ReadLine
ReadAll
ODBC
SQL

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to lividace)
 
 
Post #: 6
 
 RE: how to write text file's data to MSDE - 1/12/2007 12:45:25 AM   
  lividace

 

Posts: 5
Score: 0
Joined: 1/6/2007
Status: offline
how to split the line??

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: how to write text file's data to MSDE - 1/12/2007 3:16:00 AM   
  Country73


Posts: 735
Score: 10
Status: offline
You will need to find out how the information is listed in your text file.
More than likely they are split up by tabs.

Example of text file split by TAB:

job_id TAB job_desc
1 TAB New Hire - Job not specified
2 TAB Chief Executive Officer
3 TAB Business Operations Manager
4 TAB Chief Financial Officier


If that is the case, you can split it by just using the SPLIT command

When you read in each line you will split the line on VBTAB (vbscripts representation of TAB)

Example for reading and spliting your text file:
(code tags removed for color text use)
myTextFile = "<your file>"

SET oFS = CreateObject("Scripting.FileSystemObject")
SET oFile = oFS.GetFile(myTextFile)
SET myLine = oFile.OpenAsTextStream(1,-2)
    DO UNTIL myLine.AtEndOfStream
        mySplit = SPLIT(myLine.ReadLine,VBTAB)
        IF mySplit(0) <> "job_id" THEN 'This will skip over the first line of your text file
            myJob_ID = mySplit(0)
            myJob_Desc = mySplit(1)
           CALL writeTOsql(myJob_ID,myJob_Desc) 'You will need to create your function for writing into SQL
        END IF
    LOOP
SET myLine = NOTHING
SET oFile = NOTHING
SET oFS = NOTHING

FUNCTION writeTOsql(myJob_ID,myJob_Desc)
    <your sql coding>
END FUNCTION

< Message edited by Country73 -- 1/12/2007 3:17:05 AM >

(in reply to lividace)
 
 
Post #: 8
 
 RE: how to write text file's data to MSDE - 1/18/2007 2:40:13 AM   
  lividace

 

Posts: 5
Score: 0
Joined: 1/6/2007
Status: offline
Can bulk insert command or bulk copy command to copy the text file into MSDE??
What copy option can use to copy the text file into MSDE??

(in reply to Country73)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> how to write text file's data to MSDE Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts