请教个 sql 问题,通过这个 sql 怎么写个函数

2016-05-26 00:26:11 +08:00
 bozong
select distinct case ISNULL(p.iscomment,0) when 0 then '未评价' else '已评价' end zhuangtai from piproject p
left join PiEntpriseContacts s on p.entpriseid=s.entpriseid and s.enableflag=1
where 1=1 and p.enableflag=1 and (p.estate = 13 or p.PassNodeId=11313)
and p.CreateOn > dateadd(month,-3,GETDATE()) and (p.Mobile = '{0}' or s.mobile='{0}') and p.iscomment is null


{0}为变量
1183 次点击
所在节点    问与答
11 条回复
zhangshu
2016-05-26 07:02:01 +08:00
我记着变量传进去不是要有 @Mobile 的吗?难道是我记错了!
bozong
2016-05-26 08:46:50 +08:00
@zhangshu 输入的话{0}换成 @参数 但是不知道怎么输出
bozong
2016-05-26 09:49:40 +08:00
//////////
zhangshu
2016-05-26 13:15:25 +08:00
(Mobile=@Mobile)输入,输出:(exec ‘@Mobile :你要查的东西’)@Mobile :变量
zhangshu
2016-05-26 13:15:46 +08:00
好像是这样,你试试
bozong
2016-05-26 13:44:31 +08:00
@zhangshu 我看看
bozong
2016-05-26 14:00:49 +08:00
@zhangshu 是在 sqlserver 里面创建函数
zhangshu
2016-05-26 16:05:08 +08:00
对啊,你不是在你的数据库中,用的可编程性吗?
bozong
2016-05-26 17:09:55 +08:00
@zhangshu 标量函数吗
bozong
2016-05-26 17:10:49 +08:00
@zhangshu 方便给个扣扣吗?嘿嘿
zhangshu
2016-05-27 07:47:32 +08:00
1909622960

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/281290

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX