11

I am seeing a strange (not-documented) value for [Type] column in sys.objects. The value is "ST" as shown in the below (note, dbo.Record is a user table)

Does anyone know what this 'ST' value means? (This is in SQL Server 2014 Developer Edition)

enter image description here

3
  • Interesting. Similar question was posted to MSDN forums back in May: What is Type = ST in sys.objects?. And, that one also relates to SQL Server 2014. No answer there, though :-( Commented Nov 17, 2017 at 3:10
  • 1
    Are you using any optional product features which might be relevant? Commented Nov 17, 2017 at 20:35
  • i have run into this tyoe as well, in SQL Server 2017. When I ran a check across all DBs on the servers, there were hundreds of them. Commented May 18, 2020 at 12:37

2 Answers 2

4

Well, I don't know what ST stands for, but based on the naming convention I would have to guess it's some kind of system-generated statistic.

You could check to see if there is, by chance, some kind of text associated with the object if it is a module, e.g.:

SELECT OBJECT_DEFINITION(613577224);

SELECT definition FROM sys.all_sql_modules
  WHERE object_id = 613577224;

You could also try:

EXEC sp_help N'dbo._ST_OEA33...';

Finally, you could try to brute force discover this object in any of the catalog views. This script tries to find any view that contains a row where the object_id column is equal to that value.

CREATE TABLE #v(v sysname);

DECLARE @sql nvarchar(max) = N'', @obj int = 613577224;

SELECT @sql += N'INSERT #v 
    SELECT DISTINCT ''sys.' + name + N''' 
      FROM sys.' + QUOTENAME(name) + N' 
      WHERE [object_id] = @obj;'
  FROM sys.all_views AS v
  WHERE EXISTS 
  (
    SELECT 1 
      FROM sys.all_columns AS c
      WHERE c.name = N'object_id' 
      AND c.[object_id] = v.[object_id]
  ); 

EXEC sys.sp_executesql @sql, N'@obj int', @obj;

SELECT v FROM #v;

DROP TABLE #v;

If this yields nothing, you could expand it to include all int-based columns across all catalog views, since sometimes object_id values are stored in columns with different names, like referenced_major_id or parent_object_id, and any results here might yield clues as well.

SET NOCOUNT ON;

CREATE TABLE #v(v sysname);

DECLARE @sql nvarchar(max) = N'', @obj int = 613577224;

SELECT @sql += N'INSERT #v 
    SELECT DISTINCT ''sys.' + v.name + N''' 
      FROM sys.' + QUOTENAME(v.name) + N' 
      WHERE ' + QUOTENAME(c.name) + N' = @obj;'
  FROM sys.all_views AS v
  INNER JOIN sys.all_columns AS c
  ON v.[object_id] = c.[object_id]
  WHERE v.[schema_id] = 4
    AND c.[system_type_id] IN (56,127)
    AND v.name NOT IN (N'syscolumns')
    AND v.name NOT LIKE N'dm_fts_%'; 

EXEC sys.sp_executesql @sql, N'@obj int', @obj;

SELECT v FROM #v;

GO
DROP TABLE #v;
1
  • Thanks Aaron, I will give some run later and report back. But object_definition() and select * from sys.all_modules return either null or nothing. I also expect this is something to do with statistics, according to statistics naming convention, WA_xxx means "Washington", _ST may means SEATTLE ? :-)
    – jyao
    Commented Nov 17, 2017 at 20:14
3

ST Objects are Database Table usage Statistics. I was in a situation yesterday were we needed to delete a Schema completely on an Azure SQL Managed Instance. On trying to drop the schema, we were unable to do this, and got some long Error like ST__xxxxxx___Chinesechars..... The reason for this is the tables that were dropped now no longer belonged to a schema and their Statistics still existed in the Managed Instance sys tables.

You have 2 options. Try to drop the statistics before dropping the table using:

DROP STATISTICS [Database].[Schema].[Table];

Or move the statistics to another schema. Not the best, but will get you around the error when dropping a schema.

ALTER SCHEMA [SchemaToMoveTo] TRANSFER OBJECT::[SchemaFrom].[ST__xxxxxx___Chinesechars]

Seems to be a bug within SQL Managed Instances.

1
  • 1
    What are "Database Table usage Statistics"? Only thing I am aware of with this sort of info are DMVs that are in memory structures only and don't create entries in sys.objects AFAIK Commented Oct 27, 2020 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.