日期:2014-05-16 浏览次数:20401 次
----------------------------------------------------------------
-- Author :fredrickhu(小F,向高手学习)
-- Date :2014-03-10 10:22:53
-- Verstion:
-- Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
-- Jul 9 2008 14:43:34
-- Copyright (c) 1988-2008 Microsoft Corporation
-- Enterprise Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
--
----------------------------------------------------------------
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([pzh] varchar(12))
insert [tb]
select '2014-1-1' union all
select '2014-5-1230' union all
select '2014-10-256' union all
select '2014-11-5555'
--------------开始查询--------------------------
select parsename(replace(PZH,'-','.'),2) from tb
----------------结果----------------------------
/* --------------------------------------------------------------------------------------------------------------------------------
1
5
10
11
(4 行受影响)
*/