Running this SQL throws error Incorrect syntax near '14': SELECT * FROM sys.dm_db_index_physical_stats(14, NULL, NULL, NULL , 'LIMITED');

Salooja Johnson 1 Reputation point
2021-05-24T03:58:46.117+00:00

Tried using DB_ID(), the actual DB ID, variables etc. but it never works

Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. Anurag Sharma 17,631 Reputation points
    2021-05-24T06:12:30.697+00:00

    Hi @Salooja Johnson , welcome to Microsoft Q&A forum.

    Can you please try running queries in below format once and let me know if it works:

    SELECT * FROM sys.dm_db_index_physical_stats (DB_ID(N'yourdbname'), NULL, NULL, NULL , 'LIMITED');   
    
    
    SELECT * FROM sys.dm_db_index_physical_stats (DB_ID(N'yourdbname'), NULL, NULL, NULL , 'DETAILED');    
    

    Just replace the database name.

    If this does not work, could you please provide a screenshot of the error? Also is this an old database or something you have created recently.


  2. Salooja Johnson 1 Reputation point
    2021-06-02T22:21:55.743+00:00

    Ok thanks, if this function is not supported, then please provide details about alternate function to use.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.