首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

求教,小弟我在sql 2000能用的语句,转换到delphi里面,引号什么怎么办,用adoquery.text:=''l老是报错

2012-12-16 
求教,我在sql 2000能用的语句,转换到delphi里面,引号什么怎么处理,用adoquery.text:''l老是报

求教,我在sql 2000能用的语句,转换到delphi里面,引号什么怎么处理,用adoquery.text:=''l老是报错

帮我看看~~谢谢

insert into export(id,nf,yf,byds,sgds,bj)select e.remote_id as id,year('2012-11-13') as nf,month('2012-11-13') as yf,e.readdata as byds,'0','N' from readdata as e inner join(select distinct a.xiaoqu_name ,a.remote_id as remote_id,max(b.readtime) as readtime from user_data as a inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='EV2双月16_20日' and b. readtime>'2012-11-07' and b.readtime < '2012-11-14' group by a.xiaoqu_name,a.remote_id ) as f on e.remote_id=f.remote_id and e.readtime=f.readtime order by substring(f.remote_id,1,6),substring(f.remote_id,7,2),substring(f.remote_id,9,2)

[最优解释]
insert into export(id,nf,yf,byds,sgds,bj)
select e.remote_id as id,year('''2012-11-13''') as nf,
month('''2012-11-13''') as yf,e.readdata as byds,'''0''','''N''' 
from readdata as e 
inner join(select distinct a.xiaoqu_name ,a.remote_id as remote_id,max(b.readtime) as readtime 
from user_data as a inner join readdata as b on a.remote_id=b.remote_id
 and a.selinfo='''EV2双月16_20日''' and b. readtime>'''2012-11-07''' 
 and b.readtime < '''2012-11-14''' group by a.xiaoqu_name,a.remote_id ) as f
 on e.remote_id=f.remote_id and e.readtime=f.readtime
 order by substring(f.remote_id,1,6),substring(f.remote_id,7,2),
 substring(f.remote_id,9,2) 

[其他解释]
写在delphi中的SQL  ''=SQL语句中的'   '+'表示换行
[其他解释]

insert into export(id,nf,yf,byds,sgds,bj)select e.remote_id as id,year('2012-11-13') as nf,month('2012-11-13') as yf,e.readdata as byds,'0','N' from readdata as e inner join(select distinct a.xiaoqu_name ,a.remote_id as remote_id,max(b.readtime) as readtime from user_data as a inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='EV2双月16_20日' and b. readtime>'2012-11-07' and b.readtime < '2012-11-14' group by a.xiaoqu_name,a.remote_id ) as f on e.remote_id=f.remote_id and e.readtime=f.readtime order by substring(f.remote_id,1,6),substring(f.remote_id,7,2),substring(f.remote_id,9,2)










[其他解释]
adoquery.text:= 'INSERT INTO EXPORT'
    + '          (ID, NF, YF, BYDS, SGDS, BJ)'
    + ' SELECT   E.REMOTE_ID AS ID, YEAR (''2012-11-13'') AS NF,'
    + '          MONTH (''2012-11-13'') AS YF, E.READDATA AS BYDS, ''0'', ''N'''
    + '     FROM READDATA AS E'


    + '          INNER JOIN'
    + '          (SELECT DISTINCT A.XIAOQU_NAME, A.REMOTE_ID AS REMOTE_ID,'
    + '                           MAX (B.READTIME) AS READTIME'
    + '                      FROM USER_DATA AS A INNER JOIN READDATA AS B'
    + '                           ON A.REMOTE_ID = B.REMOTE_ID'
    + '                         AND A.SELINFO = ''EV2双月16_20日'''
    + '                         AND B.READTIME > ''2012-11-07'''
    + '                         AND B.READTIME < ''2012-11-14'''
    + '                  GROUP BY A.XIAOQU_NAME, A.REMOTE_ID) AS F'
    + '          ON E.REMOTE_ID = F.REMOTE_ID AND E.READTIME = F.READTIME'
    + ' ORDER BY SUBSTRING (F.REMOTE_ID, 1, 6),'
    + '          SUBSTRING (F.REMOTE_ID, 7, 2),'
    + '          SUBSTRING (F.REMOTE_ID, 9, 2)';
[其他解释]

  ADOQuery1.Close;
  ADOQuery1.SQL.Text:=
    'insert into export(id,nf,yf,byds,sgds,bj)select e.remote_id as id,year('
    +QuotedStr('2012-11-13')
    +') as nf,month('
    +QuotedStr('2012-11-13')
    +') as yf,e.readdata as byds,'
    +QuotedStr('0')
    +','
    +QuotedStr('N')
    +' from readdata as e inner join(select distinct a.xiaoqu_name ,'
    +'a.remote_id as remote_id,max(b.readtime) as readtime from user_data as a'
    +' inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='
    +QuotedStr('EV2双月16_20日')
    +' and b. readtime>'
    +QuotedStr('2012-11-07')
    +' and b.readtime < '
    +QuotedStr('2012-11-14')
    +' group by a.xiaoqu_name,a.remote_id ) as f on e.remote_id=f.remote_id and '


    +'e.readtime=f.readtime order by substring(f.remote_id,1,6),'
    +'substring(f.remote_id,7,2),substring(f.remote_id,9,2)';
  ADOQuery1.ExecSQL;

热点排行