How should I name my history tables ?

Hi,

I want to backup an important table every week in creating some history tables.

I would like to create a Dts job or script to create every week a table with the day and month in its name. ( like : [important_table_09-07] , [important_table_09-14],... )

Any idea

Thanks.




Answer this question

How should I name my history tables ?

  • Richard Berg MSFT

  • Dhaval-Patel

    Thanks, but how can I create a stored procedure which create a table with a name depending of the current month/day (or like TableName_YYYYMMDD). I would like to store the creation table date in its name.

    Is this possible

    Thx



  • kcdclan

    I would only use the convention TableName_YYYYMMDD. As I guess that they will be not used that often, you should consider creating them on another filegroup and even schema (if you use SQL 2k5) than the productiv one to ease up the Backup of the objects.

    HTH, Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

  • Flack

    Ok, thx.

    I'v written the stored procedure. My variable @command is correct. But how can I say to execute it

    exec @command doesn't work.

    I even tried to call the osql.exe through xp_cmdshell :)



  • rpskumar

    EXEC(@Command)
    SP_EXECUTESQL @COMMAND

    HTH, Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

  • MrBrilliant

    Hi,

    you will have to use dynamic SQL for that:


    SET @Command = 'CREATE TABLE ' + @Tablename + '_' + CONVERT(VARCHAR(8),GETDATE(),112) + (...Columnshere)

    HTH, Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---




  • How should I name my history tables ?