Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing all sequences in a SQL Server database

I tried:

SELECT * 
FROM sys.sequences

I get:

Error: The "variant" data type is not supported.
SQLState: 08S01
ErrorCode: 0

I know there are sequences. Is there a way to see sequences of a table in SQL Server Management Studio in the GUI somehow? Thanks.

EDIT: I noticed that this doesn't work with SQL Squirrel client program but the very same query can be used succesfully in SQL Server Management Studio.

like image 263
Steve Waters Avatar asked Aug 30 '17 08:08

Steve Waters


2 Answers

You can find sequences in SSMS in object explorer under Programmability:

enter image description here

like image 56
Andrea Avatar answered Oct 22 '22 01:10

Andrea


If you want to know the sequences and values, you can cast the variant types. For example the following will give most of the details you may be looking for:

SELECT
  name,
  cast(start_value AS NUMERIC)   AS start_value,
  cast(increment AS NUMERIC)     AS increment,
  cast(current_value AS NUMERIC) AS current_value
FROM sys.sequences;
like image 39
NealeU Avatar answered Oct 21 '22 23:10

NealeU