-- 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)
*/