日期:2014-05-18 浏览次数:20614 次
strSQL = 'select top '+RecordNum+' a.*'+strFiledName+' from t_db_change a left join '+TableName+' on a.id='+TableName+'.id where 1=1'+strSQL1; id表示这两个列要进行连接的列,楼主换成自己 的列
------解决方案--------------------
语句中变量太多,完全等价不好写,只写大概:
strSQL = "select top "+RecordNum+" a.*"+strFiledName+" from t_db_change a left outer join "+TableName+" where 1=1"+strSQL1;
------解决方案--------------------
你都让客户端自定义到这个程度了,表名-字段-条件
还不如让他自己传sql语句了,剩下的非变量的那几个什么select top from之类的没什么实质意义了。
------解决方案--------------------
strSQL = "select top "+RecordNum+" a.*"+strFiledName+" from t_db_change a " strSql2 = " left join "+TableName+" b on a.ID = b.ID " exec (strSql +strSql2)
------解决方案--------------------
select top 30 a.*,YWLSH as B1,SJBBH as B2,SPSXBH as B3,SPSXZXBH as B4,YXTYWLSH as B5, BJJGZZJGDM as B6,BJJGMC as B7,CONVERT(varchar,BJSJ, 121) as B8, BJJG as B9,BLJGMS as B10,ZFTHYY as B11,ZJMC as B12,ZJBH as B13, ZJYXQX as B14,FZDW as B15,SFJE as B16,JEDWDM as B17,BZ as B18,BYZDA as B19, BYZDB as B20,BYZDC as B21,CONVERT(varchar,BYZDD, 121) as B22,NEOX4MID as B23 from t_db_change a left outer join dbo.T_BANJIE b on a.DEP_value1 = b.ywlsh collate Chinese_PRC_CI_AS where 1=1 and DEP_tableName='dbo.T_BANJIE' and DEP_RuleFile='n_t_banjie' order by DEP_OID