SQL 语句能这样写吗 我要查询的是动态的 可变的SqlConnection con = new SqlConnection("server=localhost;database=7daydian;uid=sa;pwd=1234");
string dia = "dianliang"; string sql = "select '"+dia+"' from tongji order by shijian"; SqlCommand com = new SqlCommand(sql, con);
我执行了下 没有结果应该怎样写啊
在线等 急!
string dia = "dianliang"; string sql = "select '"+dia+"' from tongji order by shijian"; SqlCommand com = new SqlCommand(sql, con);
我执行了下 没有结果应该怎样写啊
在线等 急!
string sql = "select " + dia + " from tongji order by shijian";
这样写
string sql = 'select "+dia+" from tongji order by shijian';
dianliang 是字段名
3 楼的 可以 谢谢!!自己想的还是不够多 只要“dia” 就可以啦 还得学习啊
这样写泰安二手房
string sql = "select distinct [name] as 板块名称 ,[" + mon + "]as [周一]
,[" + thur + "]as [周2]
,[合计] from (select [name],[zhuzhai2],riqi,[合计]=sum([zhuzhai2])over(partition by [name]) from vw_rp_plan_houseitem where riqi>=''and dep_master_Nod='1' and BossNod='1' ) a pivot (max([zhuzhai2]) for [riqi] in( [" +mon+ "]as [周一],[" + thur + "]as [周2]))b ";
这个怎么改啊 也是动态的
",[" + thur + "] as [周2],[合计] from (select [name],[zhuzhai2],riqi,[合计]=sum([zhuzhai2])over(partition by [name]) from vw_rp_plan_houseitem where riqi>='' and dep_master_Nod='1' and BossNod='1') a pivot (max([zhuzhai2]) for [riqi] in( [" + mon + "] as [周一],[" + thur + "] as [周2])) b ";