I have a relational database, Microsoft SQL Server 6.5, which contains several tables that hold information for a loan. I want to be able to copy all the data that pertains to the loan and assign it a new loan number. Almost every table contains an Identity field. This field is used for all subsequent child tables (i.e. Table “Loan?? contains LoanID which is an identity field. Table “LoanDebt??, which is a child table of Loan, also has a LoanID [non-identity] field that refers to its parent, and it also has its own identity field LoanDebtID). I need an SQL script, compatible with Microsoft SQL Server 6.5, that will determine the current table structure and duplicate the record(s) for the loan when given the following table to work from: Table Structure --------------- TableName varchar(30) NOT NULL ParentName varchar(30) NULL SortOrder smallint NOT NULL Example Table Data ------------------ TableName ParentName SortOrder Loan Null 1 LoanSubmission Loan 2 LoanRealEstate Loan 3 MortgageSummary LoanRealEstate 4 LoanDebt Loan 5 etc.. Table Structure Examples ------------------------ Loan: LoanID int Identity(1,1), LoanAmount money,..etc LoanSubmission: LoanID int, RequestedAmount money,.. etc LoanRealEstate: LoanID int, LoanRealEstateID int Identity(1,1), Address varchar(255),..etc MortgageSummary: LoanID int, LoanRealEstateID int, MortgageSummaryID int Identity(1,1),..etc LoanDebt: LoanID int, LoanDebtID int Identity(1,1),.. etc The script will need to determine the table structure dynamically (columns are always being added), copy the record(s) back into the table, determine if an Identity exists in the table, and pass that identity down to any subsequent child tables.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done 2) Deliverables must be in ready-to-run condition, as follows? (depending on the nature? of the deliverables): a)? For web sites or? other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment. b) For all others including desktop software or software the buyer intends to distribute: A software? installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request. 3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Microsoft SQL Server 6.5