Почему не работает BCP?

senglory
Дата: 27.01.2013 19:00:05
-- http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/1c83b752-f36f-4b46-bed9-a183e2df7ff2/
EXEC sp_configure'xp_cmdshell', 1  
GO
RECONFIGURE
GO
EXEC sp_configure 'show advanced options', 1
GO



-- http://stackoverflow.com/questions/12140947/using-bcp-utility-to-export-sql-queries-to-a-text-file/14542211#14542211
declare @logtext varchar(max)
-- http://social.technet.microsoft.com/Forums/en-US/sqldatawarehousing/thread/b7dd0dbb-44ee-413a-aed3-1f7577c48a16
declare @cmd varchar(4000)

set @logtext = '"

select 
   1 as IsJur
      ,[FromCompanyName] as CompanyName
      ,[FromAreaCode] as AreaCode
      ,[iFromCountry] as Country
      ,[FromPostCode] as PostCode
      ,[iFromCity] as City
      ,[FromAddress] as Address
      ,  cast([FromTel] as NVarchar(max)) as Telephone 
      ,  [FromTel] as Telephone 
      ,[FromContactPerson] as ContactPerson
      ,[urINN] as INN
      ,[urKPP] as KPP
      ,[urOKPO] as OKPO
      ,[urOGRN] as OGRN
      ,[urUrAddr] as UrAddr
      ,[urRsVAL] as RsVAL
      ,[urRsRUR] as RsRUR
      ,[urBankName] as BankName
      ,[urBIK] as BIK
      ,[urKS] as KS
      ,[urPosition] as Position
      ,[ToContactPersonRUS] as ContactPersonRUS
      ,[ToCompanyNameRUS] as CompanyNameRUS
,''s@r.t'' as ContactEmail
FROM [tccash].[dbo].[RequestDetails]
WHERE [physPassNum] is NULL
and [FromCompanyName]  is not null

"' 

SET @cmd = 'bcp ' + @logtext + ' queryout "c:\Participants.txt"  -T' 
EXEC master..XP_CMDSHELL @cmd  



А вместо файла с выгрузкой из таблицы я получаю:
output
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]
[-d database name]
NULL

(13 row(s) affected)


ЧТо это твари не нравится?
Гавриленко Сергей Алексеевич
Дата: 27.01.2013 19:05:47
Посидите денек в бане и подумайте, как надо общаться на форуме.