• declare @TableName varchar(128);

    set @TableName = 'sysdiagrams';

    if exists

    (

    select i.rowcnt

    from sys.tables t

    join sys.sysindexes i on t.object_id = i.id

    where indid in (1,0)

    and t.name = @TableName

    )

    print 'yes'

    ;