ALTER TABLE TMPCRE ALTER COLUMN TMP_REC VARCHAR(20)
ALTER TABLE TMPCRP ALTER COLUMN TMP_REC VARCHAR(20)
ALTER TABLE TMPCCC ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPPAUCC ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPLMC ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPLMNIIF ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPING ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPAPL ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPLEG ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPLPF ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPRPP ALTER COLUMN TMP_FAC VARCHAR(20)
ALTER TABLE TMPLCV ALTER COLUMN TMP_DOC VARCHAR(20)
ALTER TABLE TMPDIA ALTER COLUMN TMP_CMS DECIMAL(14,4)
GO
DECLARE @inx_name VARCHAR(250)
SET @inx_name =(select [name] from sys.indexes where is_primary_key<>0 AND object_id = OBJECT_ID('TMPVAL'))
IF (@inx_name IS NOT NULL)
 DECLARE @CmdText VARCHAR(1000)
 SET @CmdText='ALTER TABLE TMPVAL DROP CONSTRAINT '+@inx_name
 EXEC(@CmdText)
GO
ALTER TABLE TMPVAL ALTER COLUMN TMP_NUM VARCHAR(20) NOT NULL
GO
ALTER TABLE TMPVAL ADD CONSTRAINT [PK_TMPVAL] PRIMARY KEY CLUSTERED 
(
	[TMP_PLA] ASC,
	[TMP_CIA] ASC,
	[TMP_NUM] ASC,
	[TMP_NIT] ASC
)
GO
