Crosstab Query

  • Hi. I read a post where the issue was similar to my position. I have read up on Crosstab Queries but am unsure how to implement or if they will provide a solution in my, case.

    I have two databases 'Database 1 and Database 2'. Database 1 is the starting point. Database 2 is being used to test. During testing development work as well as transactional data will be input into database 2. I would want to migrate data from the tables that hold the development work or data that I wish to keep back to database 1. So the question is, data already exists in the tables in Database 1. How would I migrate the additional data from the parent tables + child tables and retain referential integrity?

    Feedback or links to example code appreciated.

    Thank,

    Phil.

    -------------------------------------------------------------------------------------
    A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."

    Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '

    Tommy Cooper

  • Since you are talking about possible schema changes and data differences, I would suggest you look into a database differencing tool rather than starting yourself on some quest to build something yourself with T-SQL.

    Our wonderful site sponsors (Red-Gate) make a pretty good one. Click the banner at the top of the screen (of course my banner is being blocked - it looks like they used an ActiveX control?)

    Quest makes one, Idera makes one, xSQL Software makes one. They are all priced comparably. I like the Red-Gate one, but I am on this site a lot and they may have some kind of mind-control thing going on.

  • Thanks for the reply Michael. I did not intend to change the schema. What I am doing currently is deleting the data from the tables in the database I wish to migrate to (Database 2 - child then parent) then using the SET IDENTITY_INSERT I migrate in table order from database 1 back to database 2. I know there is a much smarter way of doing this.

    Hope that makes sense.

    Many Thanks,

    Phil.

    -------------------------------------------------------------------------------------
    A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."

    Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '

    Tommy Cooper

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

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