Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

I have a database backup application that I wrote that connects to a remote SQL instance and copies all database changes to my local SQL Server instance. Everything is working fine, with one small glitch that does cause a problem if I need to restore the database on the remote server.

 

In short, the app connects to the remote database and retrieves a list off all databases on the server. It then connects to my local server and retrieves the same list. It compares the list and creates the database on the local server if need be. During this process it also creates the tables, and then populates the corresponding records. It does this for each database it finds until all databases have been processed.

 

The problem that I have is that when it creates the tables it doesn't set the identity property for a specific column that is set as the primary key, int, identity, etc. If I use query analyzer to generate a script of the table, I can see that the identity column is indeed specified. However, in my code I use the following line to retrieve the table structure, but it doesn't include an identity property:

 

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'myTable'

 

Does anyone have an idea on how I can make this happen? It work be really nice if there is a way to programmatically script a table the same way it does in QA, save the script as a text file locally, and then run the script in code when I create the table. Is this possible?

 

Thanks in advance,

 

Chris

if(computer.speed == "slow")
    {  
       hamster.feed();  
    }
if(computer.speed == "really slow")
    {  
        hamster.kill();
        BuyNewHamster();
    }

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...