首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请帮忙见见那里出错了

2012-10-21 
请帮忙看看那里出错了SQL codeUSE [UPhoneCloud_Data]GO/****** Object:StoredProcedure [dbo].[U_Sp_StSe

请帮忙看看那里出错了

SQL code
USE [UPhoneCloud_Data]GO/****** Object:  StoredProcedure [dbo].[U_Sp_StSelect]    Script Date: 10/13/2012 14:44:31 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER proc [dbo].[U_Sp_StSelect]     @UserId INT,     @StoresId INT,--门店Id     @DateType INT,--日期类型1:当天2:当月3:本周4:本年5:昨天     @PageSize INT,--分页大小     @PageIndex INT,--当前页码     @Count INT OUTPUT,--     @LogLevel INT--日志等级0:服务次数1安装应用数量 As    declare @PageLowerBound int    declare @PageUpperBound int    set @PageLowerBound=@PageSize*(@PageIndex-1)    set @PageUpperBound=@PageLowerBound + @PageSize + 1    create table #tableLogs    (        IndexId int IDENTITY(1,1) NOT NULL,        StoresLogId int    )    declare @SQl nvarchar(1000)    set @SQl='select StoresLogId from U_StoresLog where 1=1'    if @UserId<>0    begin       set @SQl=@SQl + 'and UserId='+cast(@UserId as nvarchar(50))+''    end     if @StoresId <>0    begin        set @SQl=@SQl + 'and StoresId='+ CAST(@StoresId as nvarchar(50))+''    end      if @DateType<>0    begin        if @DateType=1        begin           set @SQl=@SQl + ' AND DATEDIFF(dd,LogAddtime,GETDATE())=0'        end        if @DateType=2        begin           set @SQl=@SQl + 'AND DATEDIFF(mm,LogAddtime,GETDATE())=0'        end        if @DateType=3        begin           set @SQl=@SQl + 'and datediff(wk,LogAddtime,getdate())=0'        end        if @DateType=4        begin           set @SQl=@SQl + 'and datediff(yy,LogAddtime,getdate())=0'        end        if @DateType=5        begin           set @SQl=@SQl + 'and datediff(dd,LogAddtime,getdate())=1'        end    end    if @LogLevel=0    begin        set @SQl=@SQl + 'and where LogLevel='+CAST(@LogLevel as nvarchar(50)) +''    end    else    begin        set @SQl=@SQl + 'and where LogLevel !=0'    end    set @SQl=@SQl + 'and order by LogAddtime desc'            insert into #tableLogs(StoresLogId) exec(@SQL)    SELECT U.*  FROM U_StoresLog U , #tableLogs  WHERE U.StoresLogId=#tableLogs.StoresLogId    AND #tableLogs.IndexId>@PageLowerBound AND #tableLogs.IndexId<@PageUpperBound        SELECT @Count=COUNT(StoresLogId) FROM #tableLogs     RETURN @Count


[解决办法]
自己放到sql中分析一下不就知道哪错了
[解决办法]
估计是临时表出的问题

热点排行