I set a column as LineNo and I get errors it is a keyword.
I can't find any actual documentation of this. I just see a ton of people asking the same question and a lot of speculation.
Anyone know where I can get documentation on what is going on with MS SQL and 'LineNo' keyword?
I suspect it was to provide some functionality similar to FoxPro, when it existed and Microsoft bought them out. But, in typical Microsoft fashion, never did anything with it outside of internal use.
3 Likes
It's reserved. If you've ever troubleshot a SQL Server Stored Procedure, you may have learned to do LINENO 0
after your begin statement to reset the line count otherwise it can be impossible to find where there error is given the line number sql server will give you otherwise.
I would just use LineNumber
or LineNum
.
4 Likes
Do you mean that is one of the designed uses of that keyword?
Or it is like a handy trick that happens to work?
Believe it's the intended purpose - to reset the line number to whatever you want and that is where the error code then counts off from for SQL Server. Otherwise the line number you get from an error code in a stored procedure that has an error, if you have a lot of dynamic sql spread over many line that often gets turned into 1 line, and so the line number is not very helpful. It's a useful debugging tool - I don't know what other purpose it may serve. Take a look here - sql server - What exactly does the T-SQL "LineNo" reserved word do? - Stack Overflow
I still wouldn't do it but it seems like you can still use it as long as you do your statements like SELECT [LineNo]
according to a lower down answer.
1 Like