sql存储过程
ALTER PROCEDURE frmQueryMonthlySumDQ
--@m_strDrlQD nvarchar(50),
--@m_strMonth1 nvarchar(50),
--@m_strMonth2 nvarchar(50),
--@strSQLWhere nvarchar(500),
@strSQL nvarchar(500),
@strSQL2 nvarchar(500),
@m_strRdoXL nvarchar(50)
AS
BEGIN
declare @strSQL3 nvarchar(1000)
IF(@m_strRdoXL=1)
BEGIN
set @strSQL3=@strSQL+'order by V_BSC.mergercode,XL'
EXEC (@strSQL3)
END
ELSE
BEGIN
set @strSQL3= 'select * from (' + @strSQL + ') as T1,(' + @strSQL2 + ') as T2 where T1.prod = T2.prod order by T1.MERGERCODE,T2.prod'
EXEC (@strSQL3)
END
END
go
我要在执行存储过程的时候输出strsql3,应该怎么做
执行如下
USE [cs]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[frmQueryMonthlySumDQ]
@strSQL = N'select distinct ISNULL(V_MONTHLYCAN.系列,'' '') as XL, V_BSC.mergercode,V_BSC.mergername as mergername , round(ISNULL(sum((monthlysum.selsell+monthlysum.ensell)*MONTHLYSUM.[convert]),0),0) SELL from MONTHLYSUM,V_BSC,V_MONTHLYCAN where MONTHLYSUM.AREACODE = V_BSC.号码 and MONTHLYSUM.prod=V_MONTHLYCAN.品名 and monthlysum.ymonth>=''201211''and monthlysum.ymonth<=''201211'' and V_MONTHLYCAN.系列 in (''22S-系列'',''75S-系列'') group by V_BSC.mergercode,V_BSC.mergername ,V_MONTHLYCAN.系列 ',
@strSQL2 = N'1',
@m_strRdoXL = N'1'
SELECT 'Return Value' = @return_value
GO
------解决方案--------------------ALTER PROCEDURE frmQueryMonthlySumDQ
@strSQL nvarchar(500),
@strSQL2 nvarchar(500),
@m_strRdoXL nvarchar(50),
@strSQL3 nvarchar(1000) output
AS
BEGIN
IF(@m_strRdoXL=1)
BEGIN
set @strSQL3=@strSQL+'order by V_BSC.mergercode,XL'
EXEC (@strSQL3)
END
ELSE
BEGIN
set @strSQL3= 'select * from (' + @strSQL + ') as T1,(' + @strSQL2 + ') as T2 where T1.prod = T2.prod order by T1.MERGERCODE,T2.prod'
EXEC (@strSQL3)
END
END
------解决方案--------------------
该回复被管理员删除