是否可以将变量打印到文件中?

时间:2017-07-18 10:19:52

标签: sql sql-server tsql

我想使用默认的SQL Server日志生成日志。如果我使用:

SET @IPE = 'bcp SELECT ''Test ''' + @SQLEXE  +  'queryout'  + @Path + '1b_Log_change_log_entry.txt -c '+ @Servername +' '+ @Authentification +''

它很有效,因为结果是:

Copy direction must be either 'in', 'out' or 'format'.
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]        [-K application intent]  [-l login timeout]

NULL

1 个答案:

答案 0 :(得分:0)

是的,使用bcp实用程序和参数-o