-- ============================================
-- Migration 0029: Nettoyage colonnes tables
-- Date: 2026-02-07
-- ============================================
-- Suppression de colonnes obsoletes sur diverses tables
-- Compatible WinDev (sans GO)
-- ============================================

DECLARE @constraint NVARCHAR(255)

-- ============================================
-- Supprimer les triggers de journalisation qui referencent des colonnes obsoletes
-- (sinon les DROP COLUMN echouent car le trigger reference encore ces colonnes)
-- ============================================
IF EXISTS (SELECT 1 FROM sys.triggers WHERE name = 'trigger_Option_paie_Journal')
BEGIN
    DROP TRIGGER trigger_Option_paie_Journal
    PRINT 'Trigger trigger_Option_paie_Journal supprime'
END

-- ============================================
-- Ecriture.commentaireAnalyse
-- ============================================
IF OBJECT_ID('Ecriture', 'U') IS NOT NULL AND COL_LENGTH('Ecriture', 'commentaireAnalyse') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Ecriture') AND c.name = 'commentaireAnalyse'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Ecriture DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Ecriture DROP COLUMN commentaireAnalyse')
    PRINT 'Colonne Ecriture.commentaireAnalyse supprimee'
END

-- ============================================
-- lblivr.serie_identification
-- ============================================
IF OBJECT_ID('lblivr', 'U') IS NOT NULL AND COL_LENGTH('lblivr', 'serie_identification') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('lblivr') AND c.name = 'serie_identification'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE lblivr DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE lblivr DROP COLUMN serie_identification')
    PRINT 'Colonne lblivr.serie_identification supprimee'
END

-- ============================================
-- facturec.IDabonnement_client
-- ============================================
IF OBJECT_ID('facturec', 'U') IS NOT NULL AND COL_LENGTH('facturec', 'IDabonnement_client') IS NOT NULL
BEGIN
    -- Supprimer l'index s'il existe
    IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'nix_facturec_IDabonnement_client' AND object_id = OBJECT_ID('facturec'))
    BEGIN
        DROP INDEX nix_facturec_IDabonnement_client ON facturec
        PRINT 'Index nix_facturec_IDabonnement_client supprime'
    END

    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('facturec') AND c.name = 'IDabonnement_client'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE facturec DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE facturec DROP COLUMN IDabonnement_client')
    PRINT 'Colonne facturec.IDabonnement_client supprimee'
END

-- ============================================
-- client.code_auxiliaire, client.ID_CLT_presta
-- ============================================
IF OBJECT_ID('client', 'U') IS NOT NULL AND COL_LENGTH('client', 'code_auxiliaire') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('client') AND c.name = 'code_auxiliaire'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE client DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE client DROP COLUMN code_auxiliaire')
    PRINT 'Colonne client.code_auxiliaire supprimee'
END

IF OBJECT_ID('client', 'U') IS NOT NULL AND COL_LENGTH('client', 'ID_CLT_presta') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('client') AND c.name = 'ID_CLT_presta'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE client DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE client DROP COLUMN ID_CLT_presta')
    PRINT 'Colonne client.ID_CLT_presta supprimee'
END

-- ============================================
-- fournisseur.Type
-- ============================================
IF OBJECT_ID('fournisseur', 'U') IS NOT NULL AND COL_LENGTH('fournisseur', 'Type') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('fournisseur') AND c.name = 'Type'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE fournisseur DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE fournisseur DROP COLUMN [Type]')
    PRINT 'Colonne fournisseur.Type supprimee'
END

-- ============================================
-- article.id_art_presta, article.volume, article.photo_nom
-- ============================================
IF OBJECT_ID('article', 'U') IS NOT NULL AND COL_LENGTH('article', 'id_art_presta') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('article') AND c.name = 'id_art_presta'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE article DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE article DROP COLUMN id_art_presta')
    PRINT 'Colonne article.id_art_presta supprimee'
END

IF OBJECT_ID('article', 'U') IS NOT NULL AND COL_LENGTH('article', 'volume') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('article') AND c.name = 'volume'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE article DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE article DROP COLUMN volume')
    PRINT 'Colonne article.volume supprimee'
END

IF OBJECT_ID('article', 'U') IS NOT NULL AND COL_LENGTH('article', 'photo_nom') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('article') AND c.name = 'photo_nom'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE article DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE article DROP COLUMN photo_nom')
    PRINT 'Colonne article.photo_nom supprimee'
END

-- ============================================
-- lbonrecep.pu_s
-- ============================================
IF OBJECT_ID('lbonrecep', 'U') IS NOT NULL AND COL_LENGTH('lbonrecep', 'pu_s') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('lbonrecep') AND c.name = 'pu_s'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE lbonrecep DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE lbonrecep DROP COLUMN pu_s')
    PRINT 'Colonne lbonrecep.pu_s supprimee'
END

-- ============================================
-- lfacturef.pu_s
-- ============================================
IF OBJECT_ID('lfacturef', 'U') IS NOT NULL AND COL_LENGTH('lfacturef', 'pu_s') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('lfacturef') AND c.name = 'pu_s'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE lfacturef DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE lfacturef DROP COLUMN pu_s')
    PRINT 'Colonne lfacturef.pu_s supprimee'
END

-- ============================================
-- avoirc.Nligne_xls
-- ============================================
IF OBJECT_ID('avoirc', 'U') IS NOT NULL AND COL_LENGTH('avoirc', 'Nligne_xls') IS NOT NULL
BEGIN
    -- Supprimer l'index s'il existe
    IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'nix_avoirc_Nligne_xls' AND object_id = OBJECT_ID('avoirc'))
    BEGIN
        DROP INDEX nix_avoirc_Nligne_xls ON avoirc
        PRINT 'Index nix_avoirc_Nligne_xls supprime'
    END

    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('avoirc') AND c.name = 'Nligne_xls'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE avoirc DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE avoirc DROP COLUMN Nligne_xls')
    PRINT 'Colonne avoirc.Nligne_xls supprimee'
END

-- ============================================
-- op_caisse.approvue
-- ============================================
IF OBJECT_ID('op_caisse', 'U') IS NOT NULL AND COL_LENGTH('op_caisse', 'approvue') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('op_caisse') AND c.name = 'approvue'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE op_caisse DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE op_caisse DROP COLUMN approvue')
    PRINT 'Colonne op_caisse.approvue supprimee'
END

-- ============================================
-- options_commercial.article_Arabe, options_commercial.Liste
-- ============================================
IF OBJECT_ID('options_commercial', 'U') IS NOT NULL AND COL_LENGTH('options_commercial', 'article_Arabe') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('options_commercial') AND c.name = 'article_Arabe'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE options_commercial DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE options_commercial DROP COLUMN article_Arabe')
    PRINT 'Colonne options_commercial.article_Arabe supprimee'
END

IF OBJECT_ID('options_commercial', 'U') IS NOT NULL AND COL_LENGTH('options_commercial', 'Liste') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('options_commercial') AND c.name = 'Liste'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE options_commercial DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE options_commercial DROP COLUMN Liste')
    PRINT 'Colonne options_commercial.Liste supprimee'
END

-- ============================================
-- Options_compta.journal_amortissement, Options_compta.mp
-- ============================================
IF OBJECT_ID('Options_compta', 'U') IS NOT NULL AND COL_LENGTH('Options_compta', 'journal_amortissement') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Options_compta') AND c.name = 'journal_amortissement'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Options_compta DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Options_compta DROP COLUMN journal_amortissement')
    PRINT 'Colonne Options_compta.journal_amortissement supprimee'
END

IF OBJECT_ID('Options_compta', 'U') IS NOT NULL AND COL_LENGTH('Options_compta', 'mp') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Options_compta') AND c.name = 'mp'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Options_compta DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Options_compta DROP COLUMN mp')
    PRINT 'Colonne Options_compta.mp supprimee'
END

-- ============================================
-- Option_paie: duree_max_contrat, nb_deux_contrat, supp_quainzaine,
--              Arrondi_entree, Arrondi_sortie, Repos, tolerance
-- ============================================
IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'duree_max_contrat') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'duree_max_contrat'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN duree_max_contrat')
    PRINT 'Colonne Option_paie.duree_max_contrat supprimee'
END

IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'nb_deux_contrat') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'nb_deux_contrat'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN nb_deux_contrat')
    PRINT 'Colonne Option_paie.nb_deux_contrat supprimee'
END

IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'supp_quainzaine') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'supp_quainzaine'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN supp_quainzaine')
    PRINT 'Colonne Option_paie.supp_quainzaine supprimee'
END

IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'Arrondi_entree') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'Arrondi_entree'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN Arrondi_entree')
    PRINT 'Colonne Option_paie.Arrondi_entree supprimee'
END

IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'Arrondi_sortie') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'Arrondi_sortie'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN Arrondi_sortie')
    PRINT 'Colonne Option_paie.Arrondi_sortie supprimee'
END

IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'Repos') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'Repos'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN Repos')
    PRINT 'Colonne Option_paie.Repos supprimee'
END

IF OBJECT_ID('Option_paie', 'U') IS NOT NULL AND COL_LENGTH('Option_paie', 'tolerance') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('Option_paie') AND c.name = 'tolerance'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE Option_paie DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE Option_paie DROP COLUMN tolerance')
    PRINT 'Colonne Option_paie.tolerance supprimee'
END

-- ============================================
-- societe.nb_employes, societe.nb_employes9421
-- ============================================
IF OBJECT_ID('societe', 'U') IS NOT NULL AND COL_LENGTH('societe', 'nb_employes') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('societe') AND c.name = 'nb_employes'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE societe DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE societe DROP COLUMN nb_employes')
    PRINT 'Colonne societe.nb_employes supprimee'
END

IF OBJECT_ID('societe', 'U') IS NOT NULL AND COL_LENGTH('societe', 'nb_employes9421') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('societe') AND c.name = 'nb_employes9421'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE societe DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE societe DROP COLUMN nb_employes9421')
    PRINT 'Colonne societe.nb_employes9421 supprimee'
END

-- ============================================
-- utilisateur.IDomag_client
-- ============================================
IF OBJECT_ID('utilisateur', 'U') IS NOT NULL AND COL_LENGTH('utilisateur', 'IDomag_client') IS NOT NULL
BEGIN
    SET @constraint = NULL
    SELECT @constraint = dc.name
    FROM sys.default_constraints dc
        JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
    WHERE dc.parent_object_id = OBJECT_ID('utilisateur') AND c.name = 'IDomag_client'

    IF @constraint IS NOT NULL
        EXEC('ALTER TABLE utilisateur DROP CONSTRAINT ' + @constraint)

    EXEC('ALTER TABLE utilisateur DROP COLUMN IDomag_client')
    PRINT 'Colonne utilisateur.IDomag_client supprimee'
END

-- ============================================
-- Suppression tables obsoletes
-- ============================================
IF OBJECT_ID('TABLEDESCRIPTION', 'U') IS NOT NULL
BEGIN
    DROP TABLE TABLEDESCRIPTION
    PRINT 'Table TABLEDESCRIPTION supprimee'
END

IF OBJECT_ID('entree', 'U') IS NOT NULL
BEGIN
    DROP TABLE entree
    PRINT 'Table entree supprimee'
END

IF OBJECT_ID('sortie', 'U') IS NOT NULL
BEGIN
    DROP TABLE sortie
    PRINT 'Table sortie supprimee'
END

IF OBJECT_ID('entree_sortie', 'U') IS NOT NULL
BEGIN
    DROP TABLE entree_sortie
    PRINT 'Table entree_sortie supprimee'
END

IF OBJECT_ID('Elmts_Exo', 'U') IS NOT NULL
BEGIN
    DROP TABLE Elmts_Exo
    PRINT 'Table Elmts_Exo supprimee (migree vers JSON)'
END

IF OBJECT_ID('activitesEtProfessions', 'U') IS NOT NULL
BEGIN
    DROP TABLE activitesEtProfessions
    PRINT 'Table activitesEtProfessions supprimee (migree vers JSON)'
END

IF OBJECT_ID('RequetePerso', 'U') IS NOT NULL
BEGIN
    DROP TABLE RequetePerso
    PRINT 'Table RequetePerso supprimee'
END
