Declare @ColumnName Varchar(20)
Declare @ConstraintName varchar(100)

Select @ColumnName = column_name, @ConstraintName = CONSTRAINT_NAME 
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1
AND table_name = 'Sahmiyeh'

IF UPPER(@ColumnName) <> 'SAZMAN_CODE'    
Begin
  Exec ('ALTER TABLE [dbo].[sahmiyeh] DROP CONSTRAINT ' + @ConstraintName)
  Alter Table Dbo.sahmiyeh Add Constraint Pk_Sahmiyeh Primary Key (Sazman_Code)    
End




