下面是简单的例子
String filePath = @"D:\" + FileName;
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText =
@"DECLARE @TraceId INT = (SELECT MAX(id) FROM sys.traces WITH (NOLOCK))
SET @[email protected]+1
DECLARE @File NVARCHAR(256);
Set @File= (@filePath)
SET @[email protected]+1 --Var olandan bir fazla
DECLARE @MaxFileSize BIGINT = 1 /* max size of file as MegaByte*/
DECLARE @FileCount INT = 1024 /* max file count for write*/
exec sp_trace_create @traceid = @TraceId OUTPUT,
@options = 2,
@tracefile = @File,
@maxfilesize = @MaxFileSize,
@stoptime = NULL,
@filecount = @FileCount
SELECT @TraceId";
command.Parameters.Add(new SqlParameter("@filePath", SqlDbType.NVarChar)).Value = filePath;
请问你甚至声明在所有的工作?当我尝试从SSMS中重新插入'N @ text'到'tbl_text.text`列时,我得到'Msg 207,Level 16,State 1,Line 4 无效的列名'N @ text'。 – binki 2014-07-16 14:44:42