开发者

SQL - Select Uppercase fields

i have a table, that has a column (SQL_Latin1_General_CP1_CI_AI), and has a couple of hundred rows where that column is filled in all uppercase. I would like to know if it is possi开发者_JS百科ble to select all the rows that have that field in uppercase and, ultimately if i can make an update to capitalize the fields.

I'm using SQL Management Studio on MSSQL 2005

Thanks


DECLARE @T TABLE
(
col VARCHAR(3) COLLATE SQL_Latin1_General_CP1_CI_AI
)

INSERT INTO @T 
SELECT 'foo' UNION ALL SELECT 'BAR' UNION ALL SELECT ''

UPDATE @T
SET col = STUFF(LOWER(col),1,1,LEFT(col,1)) 
WHERE col = UPPER(col) COLLATE SQL_Latin1_General_CP1_CS_AS AND LEN(col) >1

SELECT * FROM @T

Returns

(1 row(s) affected)

col
----
foo
Bar


(3 row(s) affected)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜