简单sql查询,高手请近来点拨一下,多谢 exec 'select a from table group by'+@b 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 exec ('select A from table group by '+@B) 不好意思,写错了,应该是要默认,不输入参数的时候select A from table,全部选出来输入参数的时候select A from table where B=@B,只选出B=@B的 if isnull(@B, '')='' exec('select A from table')else exec('select A from table where B='''+@B+'''') select A from table where (@B is null) or ((B=@B) and (@B is not null)) if @B is null select A from tableelse exec ('select A from table group by '+@B) 如何删除一批储存过程 求TSQL语句 最基础的索引问题 一个关于字符串的问题 关于Exists的效率问题 SQL中删除一个数据库再建一个数据库的时提示数据库已存在 如何用数据库的问题! 如何删除数据库表中的email字段的所有email记录值的第而个字母? 查询用时问题 数据库复制问题---高手请进 问一个很愚蠢的问题!! 关于informix的问题
默认,不输入参数的时候select A from table,全部选出来输入参数的时候select A from table where B=@B,只选出B=@B的
exec('select A from table')
else
exec('select A from table where B='''+@B+'''')
select A from table
else
exec ('select A from table group by '+@B)