V_INSTALLED_TABLECATALOG

Fields

Field Field Type Null Description
ID uniqueidentifier
TABLENAME nvarchar(100)
DESCRIPTION nvarchar(max)
TABLESPECXML xml
TABLESPECEXTENSIONXML xml yes
ISBUILTIN bit
ISCUSTOMIZABLE bit
ADDEDBYID uniqueidentifier
CHANGEDBYID uniqueidentifier
DATEADDED datetime
DATECHANGED datetime
TS timestamp
TSLONG bigint yes

Definition

Copy

create view dbo.V_INSTALLED_TABLECATALOG as 
with xmlnamespaces ('bb_appfx_commontypes' as common)
select
    ID,
    TABLENAME,
    DESCRIPTION,
    TABLESPECXML,
    TABLESPECEXTENSIONXML,
    ISBUILTIN,
    ISCUSTOMIZABLE,
    ADDEDBYID,
    CHANGEDBYID,
    DATEADDED,
    DATECHANGED,
    TS,
    TSLONG
from 
    dbo.TABLECATALOG 
where 
    TABLESPECXML.exist('(/*/common:InstalledProductList)[1]/common:InstalledProduct/@ID') = 0
    or
    case
        when TABLESPECXML.value('(/*/common:InstalledProductList)[1]/@EvaluationMethod', 'varchar(3)') = N'All' then
            case
                when not exists
                (
                    select null
                    from 
                        TABLESPECXML.nodes('(/*/common:InstalledProductList)[1]/common:InstalledProduct') T(c)  
                    left join 
                        dbo.INSTALLEDPRODUCTLIST on T.c.value('@ID', 'uniqueidentifier') = INSTALLEDPRODUCTLIST.ID  
                        and  
                        (  
                            len(INSTALLEDPRODUCTLIST.EXPIREDATE) = 0  
                            or  
                            getdate() <= convert(datetime, substring(INSTALLEDPRODUCTLIST.EXPIREDATE,1,4) + '-' + substring(INSTALLEDPRODUCTLIST.EXPIREDATE,5,2) + '-' + substring(INSTALLEDPRODUCTLIST.EXPIREDATE,7,2) + 'T00:00:00')  
                        )  
                    where  
                        INSTALLEDPRODUCTLIST.ID is null  
                ) then 1
                else 0
            end
        else
            case
                when exists 
                (
                    select null
                    from
                        TABLESPECXML.nodes('(/*/common:InstalledProductList)[1]/common:InstalledProduct') T(c)  
                    left join 
                        dbo.INSTALLEDPRODUCTLIST on T.c.value('@ID', 'uniqueidentifier') = INSTALLEDPRODUCTLIST.ID  
                    where  
                    (  
                        len(INSTALLEDPRODUCTLIST.EXPIREDATE) = 0  
                        or  
                        getdate() <= convert(datetime, substring(INSTALLEDPRODUCTLIST.EXPIREDATE,1,4) + '-' + substring(INSTALLEDPRODUCTLIST.EXPIREDATE,5,2) + '-' + substring(INSTALLEDPRODUCTLIST.EXPIREDATE,7,2) + 'T00:00:00')  
                    )  
                    and  
                    INSTALLEDPRODUCTLIST.ID is not null
                ) then 1
                else 0
            end
    end = 1