SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create proc selchuanwu(@lm varchar(20),@ps varchar(4))
as
declare @sql varchar(500)
declare @bc varchar(10)
set @bc='desc'
select @sql='select did as ''订单号'',kid as ''款号'',poid as ''PO号'',customer as ''客户编号'',
ddang as ''担当'',lbie as ''类别'',leibiedm.cpm as ''品名'',ddshu as ''订单数'',djia as ''单价'',
jine as ''金额'',mllu as ''毛利率'',yjmli as ''预计毛利'',qyueqi as ''签约日期'',
htqi as ''合同日期'',fkfshi as ''付款方式'',cyfshi as ''出运方式'',address as ''目的地''
from chuanwu,leibiedm
where
chuanwu.lbie=leibiedm.dm
order by '+ @lm+''+@bc
exec @sql
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER proc selchuanwu(@lm varchar(20),@ps varchar(4))
as
set @bc='desc'
select did as '订单号',kid as '款号',poid as 'PO号',customer as '客户编号',
ddang as '担当',lbie as '类别',leibiedm.cpm as '品名',ddshu as '订单数',djia as '单价',
jine as '金额',mllu as '毛利率',yjmli as '预计毛利',qyueqi as '签约日期',
htqi as '合同日期',fkfshi as '付款方式',cyfshi as '出运方式',address as '目的地'
from chuanwu,leibiedm
where
chuanwu.lbie=leibiedm.dm
order by @lm+@bc
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
但是如果我要这样
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER proc selchuanwu
as
declare @ps varchar(4)
declare @lm varchar(10)
set @bc='desc'
select did as '订单号',kid as '款号',poid as 'PO号',customer as '客户编号',
ddang as '担当',lbie as '类别',leibiedm.cpm as '品名',ddshu as '订单数',djia as '单价',
jine as '金额',mllu as '毛利率',yjmli as '预计毛利',qyueqi as '签约日期',
htqi as '合同日期',fkfshi as '付款方式',cyfshi as '出运方式',address as '目的地'
from chuanwu,leibiedm
where
chuanwu.lbie=leibiedm.dm
order by @lm+@bc
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
还是不行呀,我的存储过和如下,请帮我解决一下!
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER proc selchuanwu
as
declare @bc varchar(4)
set @bc='desc'
select did as '订单号',kid as '款号',poid as 'PO号',customer as '客户编号',
ddang as '担当',lbie as '类别',leibiedm.cpm as '品名',ddshu as '订单数',djia as '单价',
jine as '金额',mllu as '毛利率',yjmli as '预计毛利',qyueqi as '签约日期',
htqi as '合同日期',fkfshi as '付款方式',cyfshi as '出运方式',address as '目的地'
from chuanwu,leibiedm
where
chuanwu.lbie=leibiedm.dm
order by did @bc
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO