How SQL query result insert in to table?

  • Hi Team,

    Daily am taking the size of databases using "EXEC SP_Databases" and updating in a excel file manually,

    DATABASE_NAME|DATABASE_SIZE|REMARKS

    now i want to create a job to execute the above query and store the results in a table.

    New table structure is

    DATE_OF_EXECUTION | DATABASE_NAME |DATABASE_SIZE| REMARKS

    Please help me in query

  • Minnu (3/13/2013)


    Hi Team,

    Daily am taking the size of databases using "EXEC SP_Databases" and updating in a excel file manually,

    DATABASE_NAME|DATABASE_SIZE|REMARKS

    now i want to create a job to execute the above query and store the results in a table.

    New table structure is

    DATE_OF_EXECUTION | DATABASE_NAME |DATABASE_SIZE| REMARKS

    Please help me in query

    To insert recordset returned by stored procedure into table, the table column structure should exactly match the recordset one. Therefore you will need to do this:

    CREATE TABLE #todaystats (DBName SYSNAME, DBSize INT , Remarks VARCHAR(254))

    INSERT #todaystats EXEC SP_Databases

    INSERT YourStatsTable

    SELECT GETDATE(),* FROM #todaystats

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply