Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BCP

Status
Not open for further replies.

namtab

Programmer
Mar 5, 2004
8
GB
I have the following code:-

declare @cmd varchar(1000)
set @cmd = 'BCP ' + '"Operating.dbo.Mobile"' + ' out '
+ 'jingl1.txt' +' -c -S '+ @@servername + ' -Uxxx -Pxxx'
exec master..xp_cmdshell @cmd


which works fine however after reading BOL I tried putting a select Statement

declare @cmd varchar(1000)
set @cmd = 'BCP ' + '"Select * from Operating.dbo.Mobile"' + ' out '
+ 'jingl1.txt' +' -c -S '+ @@servername + ' -Uxxx -Pxxxx'
exec master..xp_cmdshell @cmd

and get the following error


Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in login 'Select * from Operating'. Login fails.

I've tried different users but still get the same. has anyone had this b4?



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top