Sysstat in SQL Query
sysstat used in SQL server to map the type of the Objects like stored procedures, triggers etc.
These are mainly used to check the availability or is created already. If it is created then we can modify or delete those things.
sysstat & 0xf examples
View:
View can be identified in a table using sysstat & 0xf = 2 in the sql query
if exists (select * from sysobjects where id = object_id('dbo.view_name') and sysstat & 0xf = 2)
drop view "dbo"."view_name"Table
User defined Table can be identified in a database using sysstat & 0xf = 3 in the sql query
if exists (select * from sysobjects where id = object_id('dbo.Table_name') and sysstat & 0xf = 3)
drop table "dbo"."Table_name"Stored Procedure
Stored Procedure in a database can be identified in a table using sysstat & 0xf = 4 in the sql query
if exists (select * from sysobjects where id = object_id('dbo.Procedure_name') and sysstat & 0xf = 4)
drop procedure dbo.Procedure_nameDefault
Default can be identified in a table using sysstat & 0xf = 6 in the sql query
if exists (select * from sysobjects where id = object_id('dbo.Default_name') and sysstat & 0xf = 3)
drop table dbo.Default_nameTrigger
Trigger can be identified in a table using sysstat & 0xf = 8 in the sql query
if exists (select * from sysobjects where id = object_id('dbo.Trigger_name') and sysstat & 0xf = 8)
drop trigger dbo.Trigger_name