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 = 'DrugHavaleh'

IF ISNULL(@ColumnName,'') = ''    
  Alter Table Dbo.DrugHavaleh Add Constraint PK_DrugHavaleh Primary Key (Autoid)    

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

IF ISNULL(@ColumnName,'') = ''    
  Alter Table Dbo.TmpDrugHavaleh Add Constraint PK_TmpDrugHavaleh Primary Key (Autoid)    
