BCP Utility

  • I am taking a class for school and I have a table created in SQL and I need to import a flat file text file into this table. I have to use the BCP command line utility and I am have a lot of problems. I have tried several commands and I keep getting a message that says I need to either choose the in,out,format option and I am choosing the "in" option. Below is the command line I am using could you tell me what I am doing wrong? I appreciate any help you can give me.

    Many Thanks

    Morgan

    bcp DatabaseName..Table in c:\textfile.txt -c -t","

  • check my script in :

    http://qa.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=148

    this one does it for you, you just specified the table, the sa pass and the file path and it imports all the data.

  • I did look at your script and I noticed that you are defining a user logon and password. When I installed SQL server on my computer I don't remember specifing a user name and password. What can I do to either set a username and password so it allows me to access the SQL Server.

    Many Thanks

    Morgan

    quote:


    check my script in :

    http://qa.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=148

    this one does it for you, you just specified the table, the sa pass and the file path and it imports all the data.


  • the default sql server user name is sa with a null password. Check with Query analizer to log with that user.

    If they are correct, then use that info to execute the sp.

  • You can use a trusted connection by using the -T option, if you specify neither -U or -T it will assume a username of sa, and if you haven't specified a -P option then you will have to enter a password.

    Simon Sabin

    Co-author of SQL Server 2000 XML Distilled

    http://www.amazon.co.uk/exec/obidos/ASIN/1904347088


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply