@sysstat & 7 ?

greenspun.com : LUSENET : SQL Server Database Administration : One Thread

Eric,

Can you tell me what does this '@sysstat & 7' mean from the partial sample code attached below?

--Code begins...

select @sysstat = sysstat, @table_id = id from sysobjects where name = @table_name

if @sysstat & 7 not in (1,3) begin select @msg = "I can't find the table "+@table_name print @msg return end --Code ends...

Thanks in advance,

Kothan.

-- Anonymous, May 25, 2000

Answers

Kothan,

sysstat is undocumented. However, the type and xtype columns which are derived from sysstat are. This is the relationship:

sysstat & 7 xtype type Object Type

----------- ----- ---- -----------------------

1 PK K PRIMARY KEY constraint

1 S S System table

1 UQ K UNIQUE constraint

3 F F FOREIGN KEY constraint

3 U U User table

So, what the code segment does is create a message if the object is not of a type associated with a table.

Hope this helps,

Eric

-- Anonymous, May 25, 2000


Eric,

Thank you very much for your explanation.

It is very interesting. I am very much interested to explore more on SQL Server. Can you give me the direction to explore more on this kinda undocumented stuff?

Thanks again for your explanation.

Kothan.

-- Anonymous, May 26, 2000


Kothan,

Try http://www.swynk.com and do a "Site/Archives Search", http://www.sqlmag.com and do a "Full Text Search", or http://www.win2000mag.com and select "Keyword, InstantDoc ID, or Source" from the pull down menu to search.

Also, judging from its title, some of the undocumented stuff might be in the SQL Server Unleashed books.

Good Luck,

Eric

-- Anonymous, May 26, 2000


Moderation questions? read the FAQ