当前位置: 动力学知识库 > 问答 > 编程问答 >

sql - Multiple select statements give multiple answer sets

问题描述:

I have a few SELECT statements that I would like to have in one SQL file.

File.sql

SELECT * FROM A

SELECT * FROM B

SELECT * FROM C

I want to run File.sql directly in Teradata and be able to see the results from the different select statements. These results are quite different and should not be in the same answer set. It doesn't matter if the reult is shown in Teradata or stored in some file. What is the easiest way to accomplish this? FYI: My user rights are limited, I can't e.g create stored procedures.

This question was considered similar to "Run multiple queries from 1 SQL file showing result in multiple tables". It is similar but not identical. The difference i mainly how the result set it represnted. In that question the requirement was to store it in one file but in this question I don't care how the result set is displayed. Hence I hope for an easier answer here.

网友答案:

without knowing what tools you have access to this is difficult to answer.

However one of the simplest ways to get multiple answer sets is using SQL Assistant.

for example: in your query window type or paste the following

  SELECT * FROM dbc.DBCInfo;
  SELECT * FROM dbc.DBCInfo;
  SELECT * FROM dbc.DBCInfo;

in your menu select file ->export results

hit F5 (or the green feet) it will prompt you for a location and filename enter where you want and file name.

it will then save the results like below

     RELEASE,14.10.02.11
     VERSION,14.10.02.12
     LANGUAGE SUPPORT MODE,Standard

     --------------------------------------------------------------------------------

     RELEASE,14.10.02.11
     VERSION,14.10.02.12
     LANGUAGE SUPPORT MODE,Standard

     --------------------------------------------------------------------------------

     RELEASE,14.10.02.11
     VERSION,14.10.02.12
     LANGUAGE SUPPORT MODE,Standard

You can also set in you options to save the sql with each query etc.

hope this helps.

网友答案:

If you can login using BTEQ then you can do the following through a script :

.LOGON env/user_id,password .SET WIDTH 3000 .SET TITLEDASHES OFF;

.EXPORT report file= file1 Select * from A;

.EXPORT report file= file2 Select * from B;

.EXPORT report file= file3 Select * from C;

.EXPORT reset; .LOGOFF ;

分享给朋友:
您可能感兴趣的文章:
随机阅读: