sql server - A generic sql query to archive more than one table -


How can we manage the collection process without writing different stored procedures in SQL Server 2000?

For example,

  • There are two tables in the current DB-student and employee.
  • The purpose data is in the archive This table -

  • Student Table - Data older than 1 year

  • employee table - data is 2 years old

    Date field to be compared in student table Field field built In addition, I have placed a configuration table with column ConfigtableName, ConfigColumnName, ConfigCutoffdate , and the employee's code DOJ

    A) How do I write a general query that it dynamically takes the name of the table and column from the configuration table and the archive is inserted in the DBS table?

    Something like this ....

      INCERT < ArchiveDb & gt; DOO & Lt; Table name from table table & gt; Choose * FROM & lt; CurrentDb & gt; .Dibo. & Lt; Table name from table table & gt; Config Table & gt; Received from WHERE & lt; ConfigColumnName & LT; & Lt; Koftfetts from the Config Table & gt;   

    b) How to manage the Field Set Option?

    c) Is it possible that an error occurs in NT repetition, then can this error be saved in the log?

    The only way to create such dynamic queries in the stored procedure is by using the stored procedure. I read the linked documents. Quite obvious.

    I'm not sure that I understand what you mean by the "Identity Field Set Option", but if you are concerned about the duplicate value in a column that has a unique value (PK) D recommends that you disable the unique index in the storage table, because they are meant to be archived, I do not think there will be a big issue with the duplicate value in the ID column, but the most important The curious thing is that the situation should never be raised, if the collection table is the same copies of the source table.

    If you want to capture errors in NT repetition, you have to include every move in the start tran / block the tran and check the errors, if any, you can choose any Others can log on the table; If not, then you commit the transaction. For example (scroll down from the All Transactions section).

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -