How to Check Teradata Table Definitions - sql

In my Teradata SQL Assistant Client, I can right-click a table and select Show Definition, this will display the column types and how they are defined.
Is there a query that can be run to give me the same output? More specifically I'm trying to display the definition of a view that is created from certain tables that I do not have SELECT or VIEW DEFINITION access to.

SHOW TABLE {Database_Name}.{Table_Name};
SHOW VIEW {Database_Name}.{View_Name};

Related

BigQuery create Table differences between standard and legacy sql

I have a few questions around the create table syntax in standard and legacy sql
The new BigQueryUI doesn't show standard sql types and shows only legacy types. I understand they are mapped one to one with the legacy types but the examples in creating partitioned tables shows options which are not available in the UI
If I create a table using the JSON field schema can I still use the standard sql?
The BigQueryUI shows only partitioning the table by Ingestion time, but I want to create a table with date column and I don't see an option for it. If I have to create the DDL manually, I did not see the examples on how to use JSON field schema to construct a create table statement.
The new BigQueryUI doesn't show standard sql types
BigQuery standardSQL and LegacySQL are 2 options to write SQL syntax (See this link for more detail) and have nothing to do with the column Types in BigQuery, Details on table types can be found in this link, I also find this Link helpful
If I create a table using the JSON field schema can I still use the standard sql?
To create a table using JSON you need to run bq command line, If you need help how to write this syntax let us know
but I want to create a table with date column and I don't see an option for it
You can use this standardSQL syntax to do this:
#standardSQL
CREATE OR REPLACE TABLE `project.dataset.tableId`
PARTITION BY myDate
CLUSTER BY cluster_col AS
SELECT * from sourceTable
Note: myDate column is a column in the source table

Crystal Report select values after generating report

I have got an sql database and want to report the data with crystal report. the problem is, that one field is generating after the report is created. so i cannot ask in the sql statement
select * from table where status like available;
I have this code in formularfield with an IF ELSE statement. How can i create a final report after generating this current report?
Thank you very much for your help.
If you have the ability to create views in the SQL database, you could create a view that you'll use as virtual look-up table for the values you want to select. Alternatively, you could build and insert a sub-report that generates that list of values you want and then link it back (or use a Shared variable) to use it in the main report.

How to create Dynamic SQL in Pentaho Report Designer?

I have a requirement where columns of the SQL will be generated based some selection, these columns are coming from Metric dimension but there is no metric ID present in Fact table.
SQL would be something like below:
SELECT Location_Nbr, Day_Nbr, (Column_List- Coming from some other query)
FROM (Table_Name - Coming from same query which is providing Columns to be selected)
I tried creating the SQL query but I get an error saying there is not a business relation between these tables. Is there any other way to achieve this?
To use Dynamic SQL in Pentaho Report Designer, you need to use
custom jdbc connection in data source
then in master report query name, select message format
type your dynamic query in message Pattern
select
$(dynamic_data) as 'data' from table_name;

Reverse Engineering a View

I was asked how to reverse engineer a view so it can be determined what columns and table were used in the sql query to produce the view . So say view 1 was constructed from the following 10 tables and 43 columns . Is this even possible in sql server 2005 ?
Use sp_helptext
exec sp_helptext 'your_view'
Edit
What you want is to find out what dependencies your view has. You can use sp_depends to do that, but it will only get you the table dependencies and not the columns.
exec sp_depends 'your_view'
In order to find out the columns you will probably have to code some kind of SQL parser to extract the columns being used from the Create View statement you recovered with sp_helptext.
You can try using a ReGex to extract the info you want or if you want a big and fancier gun you can try Irony which has a built in Sql Lexic.
Yes, in SSMS choose your database -> views -> right click -> script as CREATE.
If you want to decode a view on another database, you have no access to (e.g interface) - than this is not possible.

Create dynamic table from SQL Query

Using a hybrid Access 2010 / SQL Server 2012 platform - (a solution in either application will work)
I have a table created with a Select Into ... statement.
Is there any way to have this table dynamically update itself (using the query that created it) whenever its data is accessed?
Specifically, we want to keep a list of customers with only one order (non-repeat customers). I have created a table that contains the ID of those customers (WHERE COUNT(orderID) = 1) using Select Into, but if one of those customers makes a new order, or a new customer who makes one order is created, then I want that data removed/added to the table dynamically.
So, is this possible, or do I have to remember to update the table myself whenever I use it?
I have a table created with a Select Into ... statement. [...] Is there any way to have this table dynamically update itself (using the query that created it) whenever its data is accessed?
What you've described is a SQL VIEW, also called a "(saved) SELECT Query" in Access. A View is a virtual table that dynamically retrieves its information from other tables (or views) each time it is accessed. The view does not save its results between calls, so each time you reference it you get the most current data. See if you can use a VIEW (in SQL Server) or a saved SELECT Query (in Access) in place of the temporary table you are currently creating.