Automated Tracing with BAT File


The following script can be used to start an extended event trace and start the workload at the same time.   (copy past to a workload.bat file)

START cmd.exe /C sqlcmd -S.\SQL2016 -iscript1.sql
START /MIN /WAIT cmd.exe /C sqlcmd -S.\SQL2016 -itrace.sql

START cmd.exe /C sqlcmd -S.\SQL2016 -iscript1.sql
START /MIN /WAIT cmd.exe /C sqlcmd -S.\SQL2016 -itrace.sql

 

 

 

trace.sql:

--this is the script to create an extended event trace

EXIT(
exec PowerBITrace.dbo.StpandWaitTrace '00:00:05', 'Szenariobezeichnung hier', 1;
)

 

script1.sql

--this is the workload script

EXIT(
declare @i int = 0
while @i < 5
begin
    --Workload hier einfügen:
    SELECT 'WORLOAD 1';
    waitfor delay '00:00:01';
    Insert into testautomation values (getdate(), 'Workload1');
    ---------------------------
set @i += 1
end
)


Comments (0)

Skip to main content