What is a $pseudocolumn?

  • I captured a query similar to the following in a profiler replay trace. When replaying, it failed (as I'm sure it did when it was originally run) with this error:

    SELECT ItemValue

    FROM Item

    WHERE ItemID = $psu

    Msg 126, Level 15, State 1, Line 2

    Invalid pseudocolumn "$psu".

    I believe the client app was supposed to parse $psu out and replace it with an integer value and this is a client coding error. I don't believe the programmer intended the $psu to ever make it to the database. But since it did, I would have expected it to fail with an "Invalid column name" error, which it didn't, so I'm thinking the $ must be a special character of some kind. We'll fix the client code so that the error will go away, but can anyone explain how the $ is used and how it relates to pseudocolumns?

    Thanks,

    Chad

  • SQLCMD supports $xxx variables that are somewhat like macros and can exist across batches. With it you can write statements like:

    UPDATE $table SET ...

    or

    SELECT ..., $col, ... FROM ...

    Perhaps your trace has the unexpanded version of the script SQL.

    http://msdn2.microsoft.com/en-us/library/ms188714.aspx

  • Thanks Antonio - that does explain why SQL Server thought it was something that might have been valid.

    Chad

  • don't take my response as the gospel truth. it's just a guess/possibility. :unsure:

  • It's all good. I'm almost certain the error was a parsing mistake in the client code, I just didn't know why MSSQL didn't throw an invalid column error instead of the one it did. I figured there was something new to learn and your link gave a valid reason why SQL Server would look at $psu as something other than a column name in this context. Thank you!

    Chad

  • Invalid Pseudocolumn refers to using a variable with the $ that is not one of the recognized pseudocolumns such as $rowguid, $identity or $partition.

    And yes, it looks like a coding error in the client application.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply