What are the challenges you face when working across database platforms? Take the survey

Format wants to capitalize the OPENJSON "key" column to "Key"

I can't for the life of me find out how to stop SQL Prompt from formatting the built-in column name of "key" (must be all lower-case in my BIN2 collation for it to work) to the camel-case "Key" when I'm using a SELECT [key] FROM OPENJSON(). Is this a bug?


  • Options
    Number2Number2 Posts: 4 New member
    Now that I mention it, the [value] column also gets CamelCased to [Value] every time too.
  • Options
    James RJames R Posts: 104 Silver 4
    Hey @Number2 ,

    Just to check, have you tried turning off the formatting option under Global > Casing > User-defined objects > Use object definition case? I think that the Key and Value columns are declared as camel-case.

    If this doesn't help then let me know!
    Software Engineer
    Redgate Software
  • Options
    Number2Number2 Posts: 4 New member
    When I turn that off, then it casts them as all uppercase instead of camel.
  • Options
    way0utwestway0utwest Posts: 313 Rose Gold 1
    edited September 25, 2017 4:55PM
    Which version of SQL Prompt? If I turn off the option for user defined objects, I get things formatted as:

    DECLARE @json NVARCHAR(4000)
    = N'{
    "name" : { "firstname":"Steve", "lastname":"Jones"} ,
    "Sites":{ "primary":"SQLServerCentral", "secondary":"tsqltuesday.com"}
    SELECT [key] FROM OPENJSON(@json) AS oj
  • Options
    Number2Number2 Posts: 4 New member
    OK, I see what's happening...we've got two things causing this. One is the formatting from CTRL+K,CTRL+Y and the other is the inline-formatting/replacing feature like when you have SELECT * FROM OPENJSON() and then hit TAB when you're on that * to have it auto-expand that star into the columns. That one will also convert them to Key Value camel.

    So, with USER-DEFINED OBJECTS -> USE OBJECT DEFINITION CASE as UNCHECKED, the CTRL+K, CTRL+Y formatting does NOT exhibit this problem, but the TAB expansion of columns where it replaces text as you're typing, that DOES still camel case it for me.

Sign In or Register to comment.