开发者

How to replace the characters

开发者 https://www.devze.com 2023-02-13 17:00 出处:网络
Using SQL Server 2005 Table1 ID Abc0012 BED004开发者_StackOverflow中文版5 cAB0027 .... I want to replace all the ID values in the table1 like ABC0012, BED0045, CAB0027.

Using SQL Server 2005

Table1

ID 

Abc0012
BED004开发者_StackOverflow中文版5
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


UPDATE Table1
SET ID = UPPER(ID)


Use the UPPER function

update table1 set id = upper(id)


Use upper:

SELECT upper(ID) FROM YourTable

or:

UPDATE YourTable SET ID=upper(ID)


If you want to change them:

UPDATE  
    Table1  
SET  
    ID = UPPER(ID)

Could work, this is untested though.


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

UPDATE Table1 SET ID = UPPER(ID)


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
0

精彩评论

暂无评论...
验证码 换一张
取 消