locked
count lines of code in .sql file using ssms? RRS feed

  • Question

  • Hi,

    Is there any option/tool in ssms to count the lines of code in a .sql file?

    Need to count only lines of code eliminating the comments and blank lines/spaces.

    can anyone help in this regard.

    Wednesday, July 3, 2013 3:38 AM

Answers

  • Hi,

    Try like this ,

    In SSMS , Tools - > Options... - > Text Editor - > Plain Text - > General - > Display - >  Line numbers


    sathya --------- Mark as answered if my post solved your problem and Vote as helpful if my post was useful.

    Thursday, July 4, 2013 3:25 PM
  • In SSMS , Tools - > Options... - > Text Editor - > Plain Text - > General - > Display - >  Line numbers

    Sathya, exactly it would be " SSMS , Tools - > Options... - > Text Editor - > Transact-SQL - > General - > Display - >  Line numbers"

    Then you get in query editor window the line number at the left boarder (marked in green). The current line number is already always shown at the bottom of SSMS window as LN and COL for column; marked in red.


    Olaf Helper

    Blog Xing

    Thursday, July 4, 2013 3:53 PM
  • You can get line number as said by Satya and Olaf.. But there is no direct way to eliminate comments or blank spaces.. You need to write your own script which counts the line in .sql and eliminates comments or blank spaces.

    Mark as ANSWER if I helped you today :-) www.sql-articles.com

    Tuesday, July 9, 2013 7:22 AM

All replies

  • Hi,

    Try like this ,

    In SSMS , Tools - > Options... - > Text Editor - > Plain Text - > General - > Display - >  Line numbers


    sathya --------- Mark as answered if my post solved your problem and Vote as helpful if my post was useful.

    Thursday, July 4, 2013 3:25 PM
  • In SSMS , Tools - > Options... - > Text Editor - > Plain Text - > General - > Display - >  Line numbers

    Sathya, exactly it would be " SSMS , Tools - > Options... - > Text Editor - > Transact-SQL - > General - > Display - >  Line numbers"

    Then you get in query editor window the line number at the left boarder (marked in green). The current line number is already always shown at the bottom of SSMS window as LN and COL for column; marked in red.


    Olaf Helper

    Blog Xing

    Thursday, July 4, 2013 3:53 PM
  • You can get line number as said by Satya and Olaf.. But there is no direct way to eliminate comments or blank spaces.. You need to write your own script which counts the line in .sql and eliminates comments or blank spaces.

    Mark as ANSWER if I helped you today :-) www.sql-articles.com

    Tuesday, July 9, 2013 7:22 AM