Replace the first letter of MSSQL with a uppercase letter.

Source: Internet
Author: User
Tags microsoft sql server 2005
MSSQL converts the first letter to the implementation statement of the upper limit. For more information, see.

MSSQL converts the first letter to the implementation statement of the upper limit. For more information, see.

-- 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.