这几天用到的几个MFC中ADO方式下SqlServer语句
这两天闲着无事,写了一个MFC下对话框工程的查询小应用软件,由此引发了一系列血案:《血案五》 1.勿把sql语句中的%s与vc程序中的%s及%d混淆 sql.Format(_T("update?table set iTemp=%d where varchar1='%s'"),strTemp1,iValue);//注意加上sql语句中的单引号 2.生成虚表 sql = "字段1,substring(字段2,11,len(字段2)) as 新字段,(case substring(字段3,1,1) when '包含此字符' then '新字段' when '包含此字符' then '新字段' end)? as 新字段,substring(某字段,2,1) as 新字段,3,4)+'-'+substring(某字段,7,2)+'-'+substring(某字段,9,2) as 新字段,(case substring(某字段,2) when '等于此字符串' then '新字段' when '' then '' when '' then '' when '' then '' when '' then '' end) as 新字段,4,len(某字段)) as 新字段,convert(varchar,某字段,120) as 新字段,120) as 新字段"; 3.实现分页查询显示的基础 (当然应还有其他方法吧可能) select top 3 from table;//选出头三条记录 select? top 3 *?from?table where (某字段 not in (select top?10? from table?order by 某字段)) order by 某字段 ? 小结:唉,真是应了那句话“出来混早晚是要还滴”,当年数据库没有学好,今天是尝到了苦头。。。。。。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |