I currently use the following to dynamically alter the date range in my queries:
'${MY_DATE}'::timestamp
Is there a way to dynamically populate this rather than have the user input the value in a pop-up? I'd like to be able to run the query and it would automatically select the maximum date that exists in the table, add one day to that value and use that in the dynamic parameter throughout the queries in my script.
I've tried, something like this but it still generates the pop-up:
insert into '${MY_DATE}'::timestamp select max(SOME_DATE_FIELD) from MY_TABLE;
Thank you!
Related
I love that I can parameterize SQL queries in Pycharm. I an write a statement like so
select * from table where date >= ?
and will then be prompted for the value to be filled in for the ?.
Alas, I will be prompted afresh every time. Is there a way of specifying a set of default parameters? Bonus points for being able to pull these parameter values from a JSON/yaml file.
I am using the new scripting feature of Big Query to declare a variable and then am using that variable in a standard SQL query.
The structure of the query is :
DECLARE {name of variable} {data type};
SET {name of variable} = {Value}'
(A SQL QUERY THEN FOLLOWS USING THE ABOVE VARIABLE)
I understand that this is now a script a no longer a typical query, and thus when I run it, it runs as a sequence of executable tasks. But is there anyway in the script to explicitly state that I only want to output the resulting table of the SQL query as opposed to both the result of declaring the variable and SQL query?
What BQ Outputs
Depending on how you "capture" the output, if you are sending a query from Python/Java/CLI, then the last SELECT statement in script is the only output that you receive with the API.
Please also note that each "output" that you see come with a cost/bytes-billed, which is another reason for them to be visible at all time.
Update:
If you need to capture the output of SELECT statement to a table, depending on your intention, you may use:
CREATE OR REPLACE TABLE <your_destination_table> AS SELECT ...
or
INSERT INTO TABLE <your_destination_table> SELECT ...
I have a table with a 'query' field containing a select sql and another 'parameters' field containing the sql parameters. I have already merged these two fields into a new field containing a correct select sql statement. Now I need to execute this new field containing select sql, get the return from select (the output fields) and generate an excel file.
In your transformation, you can use the Execute row SQL script (under scripting), which does exactly what you want, executing the SQL contained in the selected input field for each row passed to the step.
Please do consider if that's really what you want. It works fine for a small set or complicated logic, but is very inefficient compared to batch inserts and updates.
If your SQL statements do look like "INSERT [some data]" and you have many rows to process, consider splitting the streams with filter steps and applying calculations or constants to each case to set the values correctly, then directing all to a table output step.
I have an SSRS report in which I've a Data Parameter. I want something like: Suppose I select a Date 10JAN2014, then when I return again to the same report I want the date parameter already set to 10JAN2014. Is it possible in SSRS ?
There is few options...
You need to create a table , use update statement which will put currently selected value ,then in
parameter properties use that column as default value.
You can also try to extract that value from execution log from report server.
I am having yet another problem with my data in ms-access.
Basically, what i'm doing is using multiple sql statements to pull, sort, and staight up change/manipulate data. The problem that im having currently is that i am trying to use a sql code like this:
UPDATE analyzedCopy2 SET analyzedCopy2.DateRange = #4/21/2009# to #4/29/2009#
but i can't figure out how to reformat DateRange (which is currently a date) to Text in the sql statement. I can't simply set the format manually because the sql code before this one is pulling in all of the data from another table and when that happens it changes the format of DateRange to date automattically since that is the type it is where it is coming from.
If anyone knows how to format a column with vba code then that would be fine too since i'm creating a vba code to run the queries in the order i want.
If anyone needs a better explanation of anything just let me know.
You can use SQL (DDL) to change some aspects of a table:
ALTER TABLE TableName ALTER COLUMN ColumnName Text(50)