4

How to get list of sequence names in Postgres?

Today,I asked how to get the sequence name list in the postgresql,Thanks to DunnoHowToCode provides the answer for me.

Now,the same question I meet in sqlsever.I through

SELECT * FROM sys.SEQUENCES

to get it,but anything I can't get.I want to get the sequence name list by sql statement in sqlsever.How can I do it?

10
  • Do you have any Sequence created in SQL SERVER Commented Jul 5, 2016 at 8:08
  • 2
    SELECT name FROM sys.SEQUENCES will return the names of all sequence objects created in your database. Commented Jul 5, 2016 at 8:08
  • 1
    What exactly is the problem you have with SELECT * FROM sys.SEQUENCES Commented Jul 5, 2016 at 8:10
  • @ZoharPeled - He already wrote that query didn't find anything Commented Jul 5, 2016 at 8:10
  • 2
    If the query doesn't return anything, there is no sequence to return. Are you looking in the correct database? Do you have permission to use the sequence ? Commented Jul 5, 2016 at 8:11

2 Answers 2

12

sys.sequences isn't broken. Your query will return all the sequences in a database as long as there are any sequences in that database. If you don't get any results, it means that there aren't any sequences. Make sure you execute the query in the correct database. Better yet, include the database name in the query, ie:

select * from mydb.sys.sequences
Sign up to request clarification or add additional context in comments.

Comments

5

You can view them in SSMS, in the Object Explorer:

enter image description here

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.