View Single Post
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: SQL command to ALTER!! PLease Help

 
0
  #3
Sep 28th, 2008
I didn't test this but if I remember right the syntax goes:

  1. Imports System.Data.OleDb
  2.  
  3. Dim strSQL As String
  4. Dim oConn As OleDb.OleDbConnection
  5. Dim oCmd As OleDb.OleDbCommand
  6.  
  7. oConn = New OleDb.OleDbConnection("<connection string>")
  8. strSQL = "ALTER TABLE <table name> ALTER COLUMN FPC_Code CONSTRAINT FPC_Code_PK PRIMARY KEY"
  9. oCmd = New OleDb.OleDbCommand(strSQL, oConn)
  10. oCmd.ExecuteNonQuery()

and this is for the combined table and assuming FPC_Code is still UNIQUE in the combined table. If you want to add PK for each hundred or so tables, dickersonka's answers gives a good starting point.
Reply With Quote