Friday, February 24, 2012

Error in bcp of trace file

Hi, i've created a trace file which shows columns EventClass, TextData, SPID
and ServerName.
I can save this to a sql table by using profiler, save as, trace table optio
n.
If however i try and create a bcp process to do this automatically, it keeps
on failing with:
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected EOF encountered in BCP
data-file
I create the table with the same definitions as the profiler has created
them ie
CREATE TABLE [dbo].[test] (
[RowNumber] [int] NULL ,
[EventClass] [int] NULL ,
[TextData] [ntext] NULL ,
[SPID] [int] NULL ,
[ServerName] [nvarchar] (128) NULL
) ON [PRIMARY]
GO
execute master.dbo.xp_cmdshell 'bcp db1.dbo.test in c:\temp\test.trc -Usa -P
-S -c'
Any suggestions?Use function fn_trace_gettable to accomplish what you want.
Example:
select * from ::fn_trace_gettable('c:\temp\test.trc', default)
go
AMB
"billu" wrote:

> Hi, i've created a trace file which shows columns EventClass, TextData, SP
ID
> and ServerName.
> I can save this to a sql table by using profiler, save as, trace table opt
ion.
> If however i try and create a bcp process to do this automatically, it kee
ps
> on failing with:
> SQLState = S1000, NativeError = 0
> Error = [Microsoft][ODBC SQL Server Driver]Unexpected EOF encountered in BCP
> data-file
> I create the table with the same definitions as the profiler has created
> them ie
> CREATE TABLE [dbo].[test] (
> [RowNumber] [int] NULL ,
> [EventClass] [int] NULL ,
> [TextData] [ntext] NULL ,
> [SPID] [int] NULL ,
> [ServerName] [nvarchar] (128) NULL
> ) ON [PRIMARY]
> GO
> execute master.dbo.xp_cmdshell 'bcp db1.dbo.test in c:\temp\test.trc -Usa
-P
> -S -c'
> Any suggestions?

No comments:

Post a Comment