Upper all my code

  • I have scripts which I want to change all the letters to upper on it.

    i.e.

    Select * from MyTable where myVar = 'RED'

    output:

    SELECT * FROM MYTABLE WHERE MYVAR = 'RED'

    I don't mind printing this out on my screen and then copying and pasting over the old script.

    I tried this but it bombs when I have single quotes in my script.

    i.e.

    DECLARE @SQL_Upper as varchar(max)

    SET @SQL_Upper = UPPER(Select * from MyTable where myVar = 'RED')

    Print(@SQL_Upper)

    any help would be appreciated.

  • GrassHopper (10/21/2016)


    I have scripts which I want to change all the letters to upper on it.

    i.e.

    Select * from MyTable where myVar = 'RED'

    output:

    SELECT * FROM MYTABLE WHERE MYVAR = 'RED'

    I don't mind printing this out on my screen and then copying and pasting over the old script.

    I tried this but it bombs when I have single quotes in my script.

    i.e.

    DECLARE @SQL_Upper as varchar(max)

    SET @SQL_Upper = UPPER(Select * from MyTable where myVar = 'RED')

    Print(@SQL_Upper)

    any help would be appreciated.

    Why do you want everything in all caps? Are every single one of your table and column names in all caps? If not you may have some challenges if you have a case sensitive collation. And if they are I would be frustrated as all caps is hard to read.

    If you already have the query in SSMS you don't need any query to do this. Just select the text and Ctrl+Shift+U. Of you can use the mouse and go Edit -> Advanced -> Make Uppercase

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • I have to convert sql scripts to hadoop and it is case sensitive and having it all in upper case makes it easier. thanks

  • GrassHopper (10/21/2016)


    I have to convert sql scripts to hadoop and it is case sensitive and having it all in upper case makes it easier. thanks

    I see. Well be careful because being case sensitive if you make everything upper you may simply be in the same boat you are in now. Good luck, that sounds like a challenge.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Highlight the text, then press Ctrl-Shift-U. And, yes, Ctrl-Shift-L will convert everything selected to lower case :-).

    Edit: That's in SSMS (just to be clear).

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Try this if it works:

    DECLARE @SQL_Upper as varchar(max)

    SET @SQL_Upper = UPPER('Select * from MyTable where myVar = ''RED''')

    Print(@SQL_Upper)

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

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