是否有可能在一个函数中有临时表? [英] Is it possible to have temp tables in a function?

查看:126
本文介绍了是否有可能在一个函数中有临时表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,我不能使用它们。我收到如下错误消息:


在函数中使用副作用运算符'SELECT'无效$

b $ b

如果我想这样做:

 从bleh中选择bleh 
到#temp

... inside a功能。

解决方案

不,每这个线程提出了相同的问题,但不能,但可以使用表变量

  DECLARE @MyTempTableVariable TABLE(SCHEMA)

INSERT INTO @MyTempTableVariable
SELECT bleh
FROM bleh


Apparently, I can't use them. I'm getting an error message like:

Invalid use of a side-effecting operator 'SELECT' within a function

If I want to do something like this:

select bleh
  into #temp
  from Blah

... inside a function.

解决方案

No, per this thread where the same question was asked, you cannot, but you can use a table variable

DECLARE @MyTempTableVariable TABLE (SCHEMA)

INSERT INTO @MyTempTableVariable
SELECT bleh
FROM bleh

这篇关于是否有可能在一个函数中有临时表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆