如何从select语句中捕获变量中的值 [英] How to capture value in a variable from select statement

查看:97
本文介绍了如何从select语句中捕获变量中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i希望从select语句中捕获变量中的所有值(例如像Employee中的Select *),并且稍后使用捕获的值在另一个询问中。

i已经尝试了很多,但我没有按照我的要求得到..

所以,请帮忙,如果有人有解决方案..



谢谢,

Raj

Hi All,

i want to capture all values in a variable from a select statement(i.e like Select * from Employee) and that captured values is later being used in another query.
i have tried a lot but i am not getting as per my requirement..
so, pls help, if any one has solution..

thanks,
Raj

推荐答案

嗨Raj,



根据您的要求,您可以使用表变量或临时表来存储输出数据。



例如:



Hi Raj,

As per your requirement you can use Table variable or Temporary table for Storing Output Data .

Eg :

Select * into #temp from Employee





以上查询创建临时表#temp并将Employee的输出存储到#temp表中



现在需要时要使用存储的数据,您只需将选择查询写为:







Above Query Create Temporary table #temp and Stores output from Employee into #temp table

Now when you want to use stored data, you can just write select Query as :


Select * from #temp







干杯!

Yogendra Dubey




Cheers !
Yogendra Dubey


这篇关于如何从select语句中捕获变量中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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