IF NOT EXISTS (
    SELECT * FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_NAME = 'PDV_VD_LINX_BINS'
)
BEGIN
    CREATE TABLE [dbo].[PDV_VD_LINX_BINS] (
        [CD_EMP] BIGINT NOT NULL DEFAULT 0,
        [CD_FILIAL] BIGINT NOT NULL DEFAULT 0,
        [CD_VD] BIGINT NOT NULL DEFAULT 0,
        [COD_BIN] VARCHAR(6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [ULTIMOS_4_DIGITOS] VARCHAR(4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL DEFAULT '',
        CONSTRAINT [PK_PDV_VD_LINX_BINS] PRIMARY KEY CLUSTERED 
        (
            [CD_EMP] ASC,
            [CD_FILIAL] ASC,
            [CD_VD] ASC,
            [COD_BIN] ASC
        )
    )

    CREATE NONCLUSTERED INDEX [IDX_PDV_VD_LINX_BINS_VENDA] ON [dbo].[PDV_VD_LINX_BINS]
    (
        [CD_EMP] ASC,
        [CD_FILIAL] ASC,
        [CD_VD] ASC
    )

    CREATE NONCLUSTERED INDEX [IDX_PDV_VD_LINX_BINS_BIN] ON [dbo].[PDV_VD_LINX_BINS]
    (
        [COD_BIN] ASC
    )

END
GO