现在有这样的一个数组 {'2011-09-01,AM','2011-09-01,PM','2011-09-02,AM’,'2011-09-03,AM','2011-09-02,PM',...,'2011-09-30,AM'}怎么样转换成{'2011-09-01,AM,PM','2011-09-02,AM,PM','2011-09-03,,PM,...'2011-09-30',AM,}
或者 原始数组怎么插入到这样的表中 Id,日期,上午,下午--ID 是GUID,日期对应数组中的日期如2011-09-01项,上午就AM存在,下午则是PM存在
或者 原始数组怎么插入到这样的表中 Id,日期,上午,下午--ID 是GUID,日期对应数组中的日期如2011-09-01项,上午就AM存在,下午则是PM存在
string[] b={ "A ", "B ", "C ", "D ", "E "}; string[] c = new string[a.Length + b.Length]; a.CopyTo(c,0);
b.CopyTo(c,a.Length); foreach(string v in c) {
Response.Write(v);
}
create table #temp(
ID int identity(1,1),
pbdate datetime,
am nvarchar(7)
)
insert into #temp
select '2011-09-01','上午'union all
select '2011-09-01','下午'union all
select '2011-09-02','下午'union all
select '2011-09-03','上午'union all
select '2011-09-03','下午'union all
select '2011-09-04','上午'union all
select '2011-09-30','下午'insert into T_HR_SJ_KQPBEntry
select pbdate, max(case am when '上午' then '上午' else '' end) as am,max(case am when '下午' then '下午' else '' end) as pm from #temp
group by pbdate
drop table #temp2011-09-01 00:00:00.000 上午 下午
2011-09-02 00:00:00.000 下午
2011-09-03 00:00:00.000 上午 下午
2011-09-04 00:00:00.000 上午
2011-09-30 00:00:00.000 下午
WC抽根烟想出这么个办法 先将数组分割下分别插入 然后用SQL 最后插入