Link to home
Start Free TrialLog in
Avatar of jaguar4u
jaguar4uFlag for United Arab Emirates

asked on

How to read from text file in SQL Server 2005

Dear Experts,

For some reason i have to read line by line from a text file and insert that text into a trigger at a specific time everyday. Is this is possible? then How? any special privileges are required for sql user? the file path and name is fixed....

Kind Regards,
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Specific privileges are always required, you need a username and password and permission to access that database.  Normally you will get that info from your database administrator.
Avatar of jaguar4u

ASKER

But how to read from a text file in SQL Server 2005?
I already have a username/password for database but do i need any store procedure to execute from msdb to process the text files?
Normally you have to write an external program to open the text file and send the lines to the database.  I don't believe it will do it by itself.
We can do it either by using OPENQUERY or SSIS package, but i don't have the syntax to do it using OPENROWSET....
You need to click on "Request Attention" above and get some other people and maybe some other zones for your question.  I haven't used either of those packages.
Avatar of hdesouky
hdesouky

Need more information to understand your problem
Are you asking to open the file to read content and insrt into database table or use the file content to create a trigger over a table?
i need to open the file to read content and insrt into database table, the contents are plain text with fixed length.
ASKER CERTIFIED SOLUTION
Avatar of hdesouky
hdesouky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be closed as follows:

Accepted answer: 0 points for jaguar4u's comment http:/Q_27410665.html#37013639

for the following reason:

Problem solved
I have already found a solution and added to the question. Hence the problem is solved now so no need for question to be up.
I don't know what is the procedure of closing a question if found the answer...

Kind Regards,

Asim
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for further clarification, i will use table variables and openrowset.
There are mutiple solutions to the questioin.
Problem can be solved with multiple solutions
I accept what ever is suggested by community