16

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.

Andrea
  • 11,801
  • 17
  • 65
  • 72
Steve Waters
  • 3,348
  • 9
  • 54
  • 94

3 Answers3

23

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;
NealeU
  • 1,264
  • 11
  • 23
15

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

enter image description here

Andrea
  • 11,801
  • 17
  • 65
  • 72
  • 2
    This is of course always an option, if you just want to see them. If you want to use them in apps, you must know how to query them ;) – campovski Aug 30 '17 at 08:21
4

What SQL Server are you using? From documentation: In SQL Server 2005 and later versions, the visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission. Are you sure you are running the script with proper permissions?

campovski
  • 2,979
  • 19
  • 38
  • I actually I just noticed the following: I used SQL Squirrel at first. The query didn't work in that. Then I tried the exact same query in SQL Management Studio an it worked. I got the list I wanted. It could have something to do how I authorize myself in each client or just in the different ways they access the database engine. – Steve Waters Aug 30 '17 at 08:13
  • 1
    Oh, SQL Squirrel. Yep, probably the program didn't have permissions. – campovski Aug 30 '17 at 08:20