I want to combine the output of this query in one table, what should i use join/union or something else?
DECLARE @name VARCHAR(1000)
DECLARE db_cursor CURSOR FOR
SELECT name FROM MASTER.dbo.sysdatabases
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
select getdate() as [Date Time], DEFAULT_DOMAIN()[Domain], SERVERPROPERTY('MachineName') AS Server,@@servername as [Instance],@name AS [Database], *
from sys.sysprocesses
FETCH NEXT FROM db_cursor INTO @name
END
CLOSE db_cursor
DEALLOCATE db_cursor