日期:2014-05-19  浏览次数:20691 次

Select 语句和存储过程的问题
select   ArticleID   From   (select   *   from   dbo.CA_NewsCenter_Article)   As   b
结果
ArticleID
22
24
25
30
31
select   ArticleID   From   (Exec   dbo.CA_NewsCenter_Article_GetArticle   ' ')   As   b
服务器:   消息   156,级别   15,状态   1,行   1
在关键字   'Exec '   附近有语法错误。
服务器:   消息   170,级别   15,状态   1,行   1
第   1   行:   ') '   附近有语法错误。

存储过程
CREATE   PROCEDURE     CA_NewsCenter_Article_GetArticle
@Getwhere   varchar(5000)= '   ',
@Selectwhere   int
AS
BEGIN
if   @Selectwhere=-1
begin
exec   ( 'select   [ArticleID],  
CA_NewsCenter_Article.ChannelID   as   ChannelID,
CA_NewsCenter_Article.ClassID   as   ClassID,
[BlogID],
[RoleGroupID],
[RoleGroupName],
[Title],
[CustomTitle],
[Keyword],
[KeywordID],
[Author],
[AuthorID],
[CopyFrom],
[Hits],
[IsOnTop],
[IsElite],
[IsPop],
[IsDeleted],
[Rank],
[Status],
[Content],
[UploadFilesUrl],
[ThumbnailUrl],
[InfoPoint],
[BonusAdd],
CA_NewsCenter_Article.ChargeType   as   ChargeType,
CA_NewsCenter_Article.PitchTime   as   PitchTime,
[ReadTimes],
CA_NewsCenter_Article.EnableComment   as   EnableComment,
[EnableCommentLink],
[EnableErrorReport],
[EnableFontChange],
[CommentCount],
[ErrorCount],
[DividePercent],
CA_NewsCenter_Article.CreatorID   as   CreatorID,
CA_NewsCenter_Article.Creator   as   Creator,
CA_NewsCenter_Article.CreateTime   as   CreateTime,
CA_NewsCenter_Article.UpdaterID   as   UpdaterID,
CA_NewsCenter_Article.Updater   as   Updater,
CA_NewsCenter_Article.UpdateTime   as   UpdateTime,
CA_NewsCenter_Article.TemplateID   as   TemplateID,
[SkinID],
[Summary],
[IncludePic],
[PaginationType],
[MaxCharPerPage],
[IsReceive],
[ReceiveUser],
[Received],
[AutoReceiveTime],
[ReceiveType],
[Copymoney],
[IsPayed],
[Beneficiary],
[PayDate],
[Subheading],
[SubjectID],
[LinkUrl],
[Assessor],
[AssessorID],
[AssessorTime],
[ClassName]
  from   CA_NewsCenter_Article,CA_Global_Class   where
  CA_NewsCenter_Article.ClassID=CA_Global_Class.ClassID
  and  
  1=1   '+@Getwhere)
end
else
begin
exec   ( 'select   top     '+@Selectwhere+ '     [ArticleID],  
CA_NewsCenter_Article.ChannelID   as   ChannelID,
CA_NewsCenter_Article.ClassID   as   ClassID,
[BlogID],
[RoleGroupID],
[RoleGroupName],
[Title],
[CustomTitle],
[Keyword],
[KeywordID],
[Author],
[AuthorID],
[CopyFrom],
[Hits],
[IsOnTop],
[IsElite],
[IsPop],
[IsDeleted],
[Rank],
[Status],
[Content],
[UploadFilesUrl],
[ThumbnailUrl],
[InfoPoint],
[BonusAdd],
CA_NewsCenter_Article.ChargeType   as   ChargeType,
CA_NewsCenter_Article.PitchTime   as &n