1
我想使用默認的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
沒有'@ SQLEXE',沒有'@Path',沒有'@ Servername',沒有'@ Authentification',我們無法幫到你。顯然,'bcp'沒有被正確使用。無論在{query}之後出現什麼,它都不是三個「in」,「out」或「format」中的一個。嘗試打印'@ IPE'並檢查其正確性。 – KtX2SkD
可能不是唯一的問題,但是您正在構建的@ IPE字符串中的'queryout'關鍵字之前或之後沒有空格,所以我認爲這可能會導致問題,除非@ SQLEXE結束一個空格和'@ Path'開頭的空格。 – 3N1GM4