Gopal
Gopal

Reputation: 11982

How to replace the characters

Using SQL Server 2005

Table1

ID 

Abc0012
BED0045
cAB0027
....

I want to replace all the ID values in the table1 like ABC0012, BED0045, CAB0027.

I want to make all characters as caps

Need Query Help

Upvotes: 1

Views: 91

Answers (6)

Ant
Ant

Reputation: 4928

Here's a complete script that shows how to use the UPPER() function to achieve this:

 declare @mytable table (
     somevalue varchar (20)
 )

 insert into @mytable(
     somevalue
 )

 values (
     'abc123'
 )

 insert into @mytable(
     somevalue
 )

 values (
     'xYz456'
 )

 insert into @mytable(
     somevalue
 )

 values (
     'gjriwe345'
 )

 update @mytable
 set somevalue = upper(somevalue)

 select *
 from @mytable

Upvotes: 1

StuperUser
StuperUser

Reputation: 10850

If you want to change them:

UPDATE  
    Table1  
SET  
    ID = UPPER(ID)

Could work, this is untested though.

Upvotes: 2

F.B. ten Kate
F.B. ten Kate

Reputation: 2032

I believe you should be able to do something like this:

UPDATE Table1 SET ID = UPPER(ID)

Upvotes: 1

Marek Grzenkowicz
Marek Grzenkowicz

Reputation: 17343

UPDATE Table1
SET ID = UPPER(ID)

Upvotes: 3

RichardTheKiwi
RichardTheKiwi

Reputation: 107716

Use the UPPER function

update table1 set id = upper(id)

Upvotes: 3

Manrico Corazzi
Manrico Corazzi

Reputation: 11371

Use upper:

SELECT upper(ID) FROM YourTable

or:

UPDATE YourTable SET ID=upper(ID)

Upvotes: 2

Related Questions