MSSQL converts the initial character to a large character

Source: Internet
Author: User
Tags microsoft sql server 2005

-- Use the program block

--> Title: generate a sequence number.
--> Author: wufeng4552
--> Date: 13:40:59
Declare @ s varchar (8000)
Set @ s = lower (@ Version)
Select @ s
/*
Microsoft SQL Server 2005-9.00.4035.00 (Intel x86)
Nov 24 2008 13:01:59
Copyright (c) 1988-2005 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (build 3790: Service Pack 2)

(A data column is affected)
*/
Declare @ I int, @ J int
Select @ I = 1, @ J = Len (@ J)
While charindex ('','' + @ s, @ I)> 0
Begin
Set @ I = charindex ('','' + @ s, @ I) + 1
If @ I> @ J continue
Set @ s = stuff (@ s, @ I-1, 1, upper (substring (@ s, @ I-1, 1 )))
End
Select @ s
/*
Microsoft SQL Server 2005-9.00.4035.00 (Intel x86)
Nov 24 2008 13:01:59
Copyright (c) 1988-2005 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (build 3790: Service Pack 2)

(A data column is affected)
*/

---- Use functions

--> Title: generate a sequence number.
--> Author: wufeng4552
--> Date: 13:40:59
If object_id ('f _ Split ') is not null drop function DBO. f_split
Go
Create Function f_split (@ s nvarchar (1000 ))
Returns nvarchar (1000)
As
Begin
Declare @ STR nvarchar (1000), @ split nvarchar (100)
Select @ s = @ s + '', @ STR =''
While charindex ('', @ s)> 0
Begin
Set @ split = left (@ s, charindex ('', @ s ))
Set @ STR = @ STR + upper (left (@ split, 1) + right (@ split, Len (@ split ))
Set @ s = stuff (@ s, 1, charindex (char (32), @ s ),'')
End
Return @ Str
End
Go
Declare @ s varchar (1000)
Set @ s = lower (@ Version)
Select DBO. f_split (@ s)
/*
Microsoft SQL Server 2005-9.00.4035.00 (Intel x86)
Nov 24 2008 13:01:59
Copyright (c) 1988-2005 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (build 3790: Service Pack 2)
*/

-- 3 borrow the system table or the hour table

--> Title: generate a sequence number.
--> Author: wufeng4552
--> Date: 13:40:59
Declare @ STR varchar (1000)
Select @ STR = char (32) + lower (@ Version)
Select @ STR = Replace (@ STR, char (32) + char (number), char (32) + char (number ))
From master .. spt_values
Where type = 'p' and number between 65 and 90
Select stuff (@ STR, 1,1 ,'')
/*
Microsoft SQL Server 2005-9.00.4035.00 (Intel x86)
Nov 24 2008 13:01:59
Copyright (c) 1988-2005 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (build 3790: Service Pack 2)

(A data column is affected)

*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.