create proc sp_AddArticleType
@strArticleTitle nvarchar(300),
@strArticlePath nvarchar(300),
@strAfileName nvarchar(100),
@strApictureId nvarchar(100),
@strAauthorName nvarchar(100),
@strIfNew nvarchar(2),
@strNewOverDate nvarchar(100),
@strType nvarchar(100)
as
@strType 是1,2,3,4,5不等的
现还想实现
for(1,2,3,4,5)
insert into Article
(ArticleTitle,ArticlePath,AfileName,ApictureId,AauthorName,IfNew,NewOverDate,AissueTime,type)
values
(strArticleTitle,strArticlePath,strAfileName,strApictureId,strAauthorName,strIfNew,strNewOverDate,getdate(),1)
@strArticleTitle nvarchar(300),
@strArticlePath nvarchar(300),
@strAfileName nvarchar(100),
@strApictureId nvarchar(100),
@strAauthorName nvarchar(100),
@strIfNew nvarchar(2),
@strNewOverDate nvarchar(100),
@strType nvarchar(100)
as
@strType 是1,2,3,4,5不等的
现还想实现
for(1,2,3,4,5)
insert into Article
(ArticleTitle,ArticlePath,AfileName,ApictureId,AauthorName,IfNew,NewOverDate,AissueTime,type)
values
(strArticleTitle,strArticlePath,strAfileName,strApictureId,strAauthorName,strIfNew,strNewOverDate,getdate(),1)
@strArticleTitle nvarchar(300),
@strArticlePath nvarchar(300),
@strAfileName nvarchar(100),
@strApictureId nvarchar(100),
@strAauthorName nvarchar(100),
@strIfNew nvarchar(2),
@strNewOverDate nvarchar(100),
@strType nvarchar(100)
asdeclare @sql nvarchar(4000)
set @sql=replace(@strType,N',',N' union all select N'''+@strArticleTitle+N''',N'''+@strArticlePath+N''',N'''+@strAfileName+N''',N'''+@strApictureId+N''',N'''+@strAauthorName+N''',N'''+@strIfNew+N''',N'''+@strNewOverDate+N''',getdate(),')exec (N'insert into Article
(ArticleTitle,ArticlePath,AfileName,ApictureId,AauthorName,IfNew,NewOverDate,AissueTime,type)
select N'''+@strArticleTitle+N''',N'''+@strArticlePath+N''',N'''+@strAfileName+N''',N'''+@strApictureId+N''',N'''+@strAauthorName+N''',N'''+@strIfNew+N''',N'''+@strNewOverDate+N''',getdate(),'+@sql)go
--没有测试,希望没错
然后在存储过程里面拆分成 1 2 3 4 5一个一个的数字?