1

I'm using the following command in SQL Server to create a temporary table, then import values from a CSV file, then consult all those values.

I'm looking for a similar way of doing this exact thing but in Teradata Database. Any import wizard tool is not a possible option for me. I want to be able to do this, only with command as I do with SQL Server.

It's possible to do this in an editor tool like Teradata SQLAssistant or Toad Data Point?

  1. create table #Temporary ( EventID int, EventEnumDays int, EventType int )

  2. BULK INSERT testdb.#temporary FROM 'C:\Users\MyUser\Desktop\bulkinsert.csv' WITH (FIELDTERMINATOR = ',');

  3. Select * from #temporary;

Thanks, any help its really appreciated!

Note: I can't use the import wizard feature of these tools, I need to use the editor window of these tools to write a query like the above to accomplish this task. is it possible?

programmer365
  • 12,641
  • 3
  • 7
  • 28
  • You say "any import wizard tool is not a possible option" yet you mention two GUI tools that do have such options. Is your real requirement to do this in a "batch" script? (In which case BTEQ may be a good choice of tool.) – Fred May 04 '20 at 16:28
  • I can't use the import wizard feature of these tools, I need to use the editor window of these tools to write a query like the above to accomplish this task. is it possible? – MultipleDatabases May 06 '20 at 01:42

1 Answers1

0

On Unix (command line script):

bteq <<EOF
.LOGON ${server}/${usr},${pwd};

create table Temp_table ( EventID int, EventEnumDays int, EventType int );

.IMPORT REPORT FILE = /home/your_name/bulkinsert.csv

.REPEAT * 
 USING 
        EventId    (varchar(10))
        ,EventEnumDays   (varchar(10))
        ,EventType (varchar(10))

 INSERT INTO Temp_table
        VALUES (
        cast(:EventId as int),
        cast(:EventEnumDays as int),
        cast(:EventType as int)
        );
select * from Temp_table;
.QUIT
.LOGOFF

EOF
access_granted
  • 1,276
  • 13
  • 20
  • Thanks for your answer. But I need to use the editor window of Teradata SQL assistant or Toad Data Point to write a query like the above to accomplish this task. is it possible? – MultipleDatabases May 06 '20 at 01:43
  • Neither of those tools allow you to specify the location of a source file via command within the editor window. If you use BTEQ (including the Windows GUI BTEQwin) then you can use a script similar to the Linux one above. – Fred May 06 '20 at 17:13