日期:2014-05-16 浏览次数:20713 次
select billno,substring(convert(char(08),billdate),1,6) from spyPartsWareOutM
if object_id('[spyPartsWareOutM]') is not null drop table [spyPartsWareOutM]
create table [spyPartsWareOutM] (billno varchar(13),billdate int)
insert into [spyPartsWareOutM]
select 'FSPO140121001','20140121' union all
select 'FSPO140121002','20140121' union all
select 'FSPO140121003','20140121' union all
select 'FSPO140121004','20140121' union all
select 'FSPO140122001','20140122' union all
select 'FSPO140122002','20140122' union all
select 'FSPO140122003','20140122'
select * from [spyPartsWareOutM]
select billno,convert(varchar(7),CONVERT(DATETIME,CONVERT(VARCHAR,billdate)),120) AS billdate from spyPartsWareOutM
/*
billno billdate
FSPO140121001 2014-01
FSPO140121002 2014-01
FSPO140121003 2014-01
FSPO140121004 2014-01
FSPO140122001 2014-01
FSPO140122002 2014-01
FSPO140122003 2014-01*/