andyrobins
Technical User
Hello.
I have recently started using transact SQL and have come across a small problem. I'm trying to launch a list of Perfmon files from within a cursor using xp_cmdshell. The problem is that it appears to wait until the launched application has terminated before it will cursor onto the next list within the table. Below is the code that I am using.
DECLARE @cursor VARCHAR(100)
DECLARE @tblname VARCHAR(50)
DECLARE @dayname VARCHAR(50)
DECLARE @server VARCHAR(100)
DECLARE @launchpml VARCHAR(100)
SET @dayname=(SELECT DATENAME(WEEKDAY, GETDATE()))
SET @tblname='servers_'+@dayname
SET @cursor='DECLARE svr_cursor CURSOR FOR SELECT servers FROM '+@tblname
EXEC(@cursor)
OPEN svr_cursor
FETCH NEXT FROM svr_cursor INTO @server
WHILE(@@fetch_status=0)
BEGIN
SET @launchpml='start perfmon4 d:\perfmon_templates\'+@dayname +'\' +@server
EXEC master..xp_cmdshell @launchpml
FETCH NEXT FROM svr_cursor INTO @server
END
CLOSE svr_cursor
DEALLOCATE svr_cursor
I am a bit new to this so I don't doubt that it is the wrong way of going about it so feel free to correct anything!!!!
I have recently started using transact SQL and have come across a small problem. I'm trying to launch a list of Perfmon files from within a cursor using xp_cmdshell. The problem is that it appears to wait until the launched application has terminated before it will cursor onto the next list within the table. Below is the code that I am using.
DECLARE @cursor VARCHAR(100)
DECLARE @tblname VARCHAR(50)
DECLARE @dayname VARCHAR(50)
DECLARE @server VARCHAR(100)
DECLARE @launchpml VARCHAR(100)
SET @dayname=(SELECT DATENAME(WEEKDAY, GETDATE()))
SET @tblname='servers_'+@dayname
SET @cursor='DECLARE svr_cursor CURSOR FOR SELECT servers FROM '+@tblname
EXEC(@cursor)
OPEN svr_cursor
FETCH NEXT FROM svr_cursor INTO @server
WHILE(@@fetch_status=0)
BEGIN
SET @launchpml='start perfmon4 d:\perfmon_templates\'+@dayname +'\' +@server
EXEC master..xp_cmdshell @launchpml
FETCH NEXT FROM svr_cursor INTO @server
END
CLOSE svr_cursor
DEALLOCATE svr_cursor
I am a bit new to this so I don't doubt that it is the wrong way of going about it so feel free to correct anything!!!!