Converting a TSQL statement to Teradata SQL

Database
Enthusiast

Converting a TSQL statement to Teradata SQL

Hello.

I currently have the following code in SQL server:

 

IF OBJECT_ID (N'PRJ_QA.dbo.TEST', N'U') IS NOT NULL
 BEGIN
    SELECT COUNT(*) AS [ OLD_COLON_VALID ] FROM
PRJ_QA.dbo.TEST;

 

I'm curious what the Teradata equivalent to this code would be.

 

thanks.

1 REPLY
Teradata Employee

Re: Converting a TSQL statement to Teradata SQL

One way to do it in a stored procedure:

 

Declare Exists int;

select count(*) from DBC.TABLESV where DatabaseName = 'PRJ_QA' and TableName = 'dbo_TEST' into :Exists;
If :Exists > 0
then
    SELECT COUNT(*) AS OLD_COLON_VALID FROM PRJ_QA.dbo_TEST;
    ...
end if;

 

Note that there is only one high-level qualifier of a table name in Teradata, so I changed the table name from dbo.TEST to dbo_TEST.