2012年3月19日星期一

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
ThanksOriginally 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 (youll 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|||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.|||True, post the code used and BCP is a command link utility and not pertained to default to any database.

没有评论:

发表评论