用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)...

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

FDQuery sqlserver 临时表的更多相关文章

  1. sqlserver 临时表、表变量、CTE的比较

    原文地址:  sqlserver 临时表.表变量.CTE的比较 1.临时表 1.1 临时表包括:以#开头的局部临时表,以##开头的全局临时表. 1.2 存储 不管是局部临时表,还是全局临时表,都会放存 ...

  2. Oracle、SqlServer——临时表

    一.oracle 1.概述: oracle数据库的临时表的特点: 临时表默认保存在TEMP中: 表结构一直存在,直到删除:即创建一次,永久使用: 不支持主外键. 可以索引临时表和在临时表基础上建立视图 ...

  3. SqlServer 临时表

    SqlServer中临时表分为两种:一种是局部(本地)临时表,用#TableName表示.一种是全局(服务器)临时表,用##TableName表示. 创建临时表: 1. create table #T ...

  4. SqlServer——临时表

    1.表的类型: SqlServer数据库中分为两个表:永久表.临时表:通过表名的前缀区分. 永久表:与物理文件.C# 中的静态类 类似,任何用户均可对其执行操作并且相互影响: 临时表:简单的说就是使用 ...

  5. SQLServer 临时表的使用

    临时表在Sqlserver数据库中,是非常重要的,下面就详细介绍SQL数据库中临时表的特点及其使用,仅供参考. 临时表与永久表相似,但临时表存储在tempdb中,当不再使用时会自动删除.临时表有两种类 ...

  6. sqlserver临时表操作

    创建临时表        方法一:      create table #临时表名(字段1 约束条件,                       字段2 约束条件,                  ...

  7. SqlServer 临时表 与 表变量(转)

    1. 表变量 变量都以@或@@为前缀,表变量是变量的一种,另外一种变量被称为标量(可以理解为标准变量,就是标准数据类型的变量,例如整型int或者日期型DateTime).以@前缀的表变量是本地的,因此 ...

  8. SqlServer 临时表、表变量、函数 替代游标

    http://www.cnblogs.com/chongzi/archive/2011/01/19/1939106.html 临时表 存放在tempdb中 --存储过程中将多表连接结果写入到临时表中, ...

  9. sqlserver临时表排序问题

    在2005和2008中,如果将有序的记录插入临时表,则从临时表查看出来的记录是有序的(不使用Order by也是有序状态) 但从2012开始,即使插入的记录集是有序的,查看出来的结果变得无序了,需要依 ...

随机推荐

  1. git 使用和安装

    http://www.git-scm.com/download/ http://www.git-scm.com/download/win http://www.git-scm.com/download ...

  2. vim with space-vim

    space-vim https://github.com/liuchengxu/space-vim macOS # homebrew /usr/bin/ruby -e "$(curl -fs ...

  3. vs警告 当前源代码跟内置的版本不一致解决办法

    本文转载于:http://blog.csdn.net/bull521/article/details/51334464 vs警告 当前源代码跟内置的版本不一致解决办法 1.删除掉 我的文档/visua ...

  4. 配置Spring Boot通过@ConditionalOnProperty来控制Configuration是否生效

    Spring boot中有个注解@ConditionalOnProperty,这个注解能够控制某个configuration是否生效. 具体操作是通过其两个属性name以及havingValue来实现 ...

  5. Linux中查看进程和杀掉进程

    ps -A查看正在运行的所有进程 kill -9 xxx杀掉某个进程,xxx为进程ID.

  6. js中字符串处理成数字的方法

    <script> var a="11.1111"; var b="12.2222"; //第一种方法:乘以1的方法 //alert(a*1+b*1) ...

  7. SGU 132. Another Chocolate Maniac 状压dp 难度:1

    132. Another Chocolate Maniac time limit per test: 0.25 sec. memory limit per test: 4096 KB Bob real ...

  8. 什么是API?我们常说调用API

    如果你不知道 API 是什么,说明你英语真的很差. API 就是 Application Programming Interface 三个单词,如果你不能顾名思义的话,我就举例说明. 1. DOM A ...

  9. Linux:有趣的命令(更新)

    有趣的命令 oneko命令 执行后会有一只小猫跟着鼠标跑 yum install -y oneko oneko 鼠标拖动那只猫 取消Ctrl+c sl命令 执行后有一火车跑过 yum install ...

  10. Zabbix proxy 3.2安装部署

    zabbix proxy 前提环境: CentOS 6 LNMP(php) 版本:Zabbix-3.2.3 proxy安装 yum install -y net-snmp \ net-snmp-dev ...