CREATE PROCEDURE DBO.XATUALIZA_SALARIO (@SITAUCAO CHAR) AS
BEGIN
/* VERIFICA SE A TABELA XSALARIO EXISTE, E DROPA */
IF EXISTS
( SELECT TOP 1 1
FROM SYSOBJECTS
WHERE SYSOBJECTS.XTYPE = 'U'
AND SYSOBJECTS.NAME = 'XSALARIO')
BEGIN
DROP TABLE XSALARIO
END
/* CRIA A TABELA XSALARIO */
CREATE TABLE XSALARIO (
CHAPA VARCHAR(10),
NOME VARCHAR(100),
SAL_ANTIGO FLOAT,
SAL_ATUAL FLOAT
)
/* DADOS PARA PREENCHER A TABELA XSALARIO */
INSERT INTO XSALARIO
SELECT CHAPA, NOME, SALARIO AS SAL_ANTIGO, (SALARIO * 1.10) AS SAL_ATUAL
FROM PFUNC
WHERE CODSITUACAO <> @SITAUCAO
END