Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: bcp only runs on master database

    Hello,

    I can't get bcp to run on any database but 'master'. I get a 'failed to login' error. i'm logged in as 'sa' with full permissions.

    Please help
    Thanks

  2. #2
    Join Date
    Mar 2004
    Location
    Austria
    Posts
    4

    Re: bcp only runs on master database

    Originally posted by markfraser
    Hello,

    I can't get bcp to run on any database but 'master'. I get a 'failed to login' error. i'm logged in as 'sa' with full permissions.

    Please help
    Thanks
    Here is an example how to do it with VB (you´ll find this example at the help of MS SQL Server and will help you to do it from within Query analizer too I guess.

    Peter

    The following Microsoft Visual Basic® code uses the BulkInsertTask object to insert data from file D:\DTS_UE\BCPData\Payroll.txt into table Payroll of database DTS_UE.

    Public Sub Main()
    'initialize Payroll table in DTS_UE db with bulk data
    Dim objPackage As DTS.Package2
    Dim objConnect As DTS.Connection2
    Dim objStep As DTS.Step
    Dim objTask As DTS.Task
    Dim objBulkCopy As DTS.BulkInsertTask

    Set objPackage = New DTS.Package

    'create database connection
    Set objConnect = objPackage.Connections.New("SQLOLEDB.1")
    With objConnect
    .ID = 1
    .DataSource = "(local)"
    .UseTrustedConnection = True
    End With
    objPackage.Connections.Add objConnect
    'create step and task, specify data file and format
    Set objStep = objPackage.Steps.New
    Set objTask = objPackage.Tasks.New("DTSBulkInsertTask")
    Set objBulkCopy = objTask.CustomTask
    With objBulkCopy
    .Name = "BulkInsTask"
    .DataFile = "D:\DTS_UE\BCPData\Payroll.txt"
    .ConnectionID = 1
    .DestinationTableName = "DTS_UE..Payroll"
    .FieldTerminator = "|"
    .RowTerminator = "\r\n"
    End With

    'link step to task to package, run package
    objStep.TaskName = objBulkCopy.Name
    objStep.Name = "BulkInsStep"
    With objPackage
    .Steps.Add objStep
    .Tasks.Add objTask
    .FailOnError = True

    .Execute
    End With
    End Sub

  3. #3
    Join Date
    Sep 2003
    Posts
    522

    Re: bcp only runs on master database

    Originally posted by markfraser
    Hello,

    I can't get bcp to run on any database but 'master'. I get a 'failed to login' error. i'm logged in as 'sa' with full permissions.

    Please help
    Thanks
    do you have an admin on your team other than yourself? post your bcp.

  4. #4
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    True, post the code used and BCP is a command link utility and not pertained to default to any database.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •