0
我試圖用一個命令行輸出一個txt文件。 但是出於某種原因不希望文本和測試名稱添加到它.. 這裏是我的代碼:在sql中添加自定義文本+變量到varchar
declare @command AS varchar(200)
declare @cmd AS varchar(200)
declare @input AS varchar(200)
declare @timeinput AS varchar(200)
declare @test AS varchar(1000)
declare @failureid as int
select @timeinput = (select time from inserted)
select @input = (select action from inserted)
select @failureid = (select failureId from inserted)
select @test = (select name from dbo.Alert where FailureId = @failureid)
if (@input = 'start')
BEGIN
set @command = ('EnableTest' + @test)
END
if (@input = 'stop')
BEGIN
set @command = ('DisableTest' + @test)
END
if (@input = 'pauze')
set @command = ('PauseTest' + @test + @timeinput)
END
SET @cmd = 'echo ' + @command + ' > F:\commandfolder\testing.HMS'
EXECUTE Master.dbo.xp_CmdShell @cmd
,並在HMS文件的輸出:DisableTest(與測試名失蹤) @test不會添加到文件中。
據我所知,我的表中的數據是正確的 任何想法?
預先感謝&親切的問候,
戴夫
我會去看看會發生什麼 –