日期:2014-05-18 浏览次数:20397 次
if OBJECT_ID('pro_test')is not null drop proc pro_test go create proc pro_test ( @teachername varchar(10), @stuname varchar(50), @state bit ) as begin --创建临时表存储你传进来的数据 if OBJECT_ID('temp..#test')is not null drop table #test create table #test( teachername varchar(10), stuname varchar(50), [state] bit ) --插入数据 insert #test select @teachername,@stuname,@state --将你传来的数据进行以下查询处理后在插入考勤表 insert 考勤表 select A.teachername, B.stuname,A.[state] from( select teachername,stuname=convert(xml,' <root> <v>' + replace(stuname, ',', ' </v> <v>') + ' </v> </root>'),[state] from #test )A outer apply( select stuname = N.v.value('.', 'varchar(100)') from A.stuname.nodes('/root/v') N(v) )B end