user3991213
user3991213

Reputation:

Converting all upper case to lower case in SQL server?

I want to update every row in my table from upper case to lower case. I searched everywhere but could not found relevant answer. I dont want it to select using SELECT. I would like to alter permanently may be using ALTER. I am using SQL server 2008. Thanks.

Upvotes: 9

Views: 52404

Answers (3)

Kamran
Kamran

Reputation: 485

You can do this using string functions:

UPDATE MyTable SET MyColumn = LOWER(MyColumn)

Upvotes: 2

Harsh Gupta
Harsh Gupta

Reputation: 4538

UPDATE table_name SET col1 = LOWER(col1), col2 = LOWER(col2), col3 = LOWER(col3);

HTH

Edit: Updating multiple columns. Just keep on adding columns like above. There is no direct automated way to update all the columns with a single command. Well, technically it may be possible using cursors, but I would advise against it since this looks like a one time process and you are better off with writing a command once and for all.

Upvotes: 27

zmbq
zmbq

Reputation: 39013

There's the LOWER function. You'll need to UPDATE your table:

UPDATE mytable SET charfld1=LOWER(charfld1), charfld2=LOWER(charfld2), ...

Put all your textual fields after the SET.

Upvotes: 1

Related Questions