Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Microsoft SQL Server Новый топик    Ответить
 Почему не работает BCP?  [new]
senglory
Member

Откуда:
Сообщений: 107
-- 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 янв 13, 19:00    [13835965]     Ответить | Цитировать Сообщить модератору
 Re: Почему не работает BCP?  [new]
Гавриленко Сергей Алексеевич
Member

Откуда:
Сообщений: 37254
Посидите денек в бане и подумайте, как надо общаться на форуме.
27 янв 13, 19:05    [13835980]     Ответить | Цитировать Сообщить модератору
Все форумы / Microsoft SQL Server Ответить