I need to populate table with data using a stored procedure using a cursor. Basically, I have a table with the following columns: ServerName, DBName, State. I am actually needing to monitor database state.
Can you please explain what you're actually trying to do? Are you trying to create a table which holds ServerName, DBName and State? You could use the below to load that. Why do you need a CURSOR? Do you have linked servers? SELECT @@servername AS 'ServerName' , name AS 'DatabaseName' , state_desc AS 'State' FROM sys.databases