zoukankan      html  css  js  c++  java
  • FDQuery sqlserver 临时表

    用FDQuery执行创建临时表,查不到临时表,用ADOQuery和BDEQuery均正常,比较发现用ADOQuery执行的时候只有SQL没有调用sql的系统存储过程sp_prepexec.

    是fdquery哪里设置的问题吗,用FDConnection->ExecSQL("sql");是可以查到临时表不调用系统存储过程sp_prepexec但是不能获得影响的行数,

    set @p1=NULL 改为NULL创建的临时表可以查到,但是如何才能设置到NULL。

    declare @p1 int
    set @p1=1
    exec sp_prepexec @p1 output,NULL,N'select top 50 *  into #ls from  myTable'
    select @p1
    go

    --------------------
    exec sp_unprepare 1 go exec [adb].[sys].sp_pkeys N'#ls',N'dbo',N'adb' go declare @p1 int set @p1=NULL exec sp_prepexec @p1 output,NULL,N'select top 50 * from #ls ' select @p1 go

    FDConnection.ResourceOptions.DirectExecute := True;

    或者

    dm->FDConnection1->ExecSQL(sql);

     这样就解决了!!

    qry->ResourceOptions->DirectExecute=true;

    http://docs.embarcadero.com/products/rad_studio/firedac/frames.html?frmname=topic&frmfile=uADCompClient_TADRdbmsDataSet_ResourceOptions.html

    对sql server有啥执行效果的区别,没有说明

    Description

    Use DirectExecute property to specify should FireDAC prepare SQL statement before execution (False) or execute it directly (True). The default value is False. 

    This property was introduced at first for MS SQL Server support. Where prepared and direct execution may have different effects. Or even prepared execution may fail. If you will get "strange" errors, then try to set DirectExecute to True.

     

     

    还有一个办法,

    exec sp_executesql N'select * into #ls from mytable'

    select * from #ls

    这样是访问不到临时表的,可以在命令前先create talbe #ls(a int)...

    这个就是先创建临时表,得知道有哪些字段。

  • 相关阅读:
    System lock
    skip_slave_start
    慢查询日志分析
    wait_timeout 、interactive_timeout、slave_net_timeout、master_heartbeat_period
    reset slave,reset slave all,reset master都干了些啥?
    强制删除有外键约束的数据
    集群拓扑结构变更
    在线开启gtid与在线关闭gtid
    less
    pg流复制
  • 原文地址:https://www.cnblogs.com/cb168/p/4361970.html
Copyright © 2011-2022 走看看