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)

解决方案 »

  1.   

    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)
    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
    --没有测试,希望没错
      

  2.   

    翻译一下楼主意思,不知道对不对,楼主是希望 将1,2,3,4,5....赋给参数@strType,
    然后在存储过程里面拆分成 1     2    3    4    5一个一个的数字?