I have a table with bigQuery update commands, for example:
Row is: UPDATEtableAS t2 SET chr3_3268035_CT=1 FROMsorted_500AS t1 WHERE t1.sample_id = t2.sample_id AND t1.PIK3CA_features="chr3_3268035_CT"
Is there a way to send this table column for execution?
Many thanks!
You cannot directly execute commands listed in your table, but you could write a script to read a series of commands from a table and then execute them.
Related
I have an SQL Job which takes two values out of a table and merges them together.
After the merge, these two values are deleted.
If the table is empty, the Job produces Error-Messages.
How can i prevent this?
Kind regards
You would add a condition to check for an empty table:
if exists (select 1 from t)
begin
-- the merge code or procedure call here
end;
I want to find the sql server agent jobs that operate upon a particular table. For ex:
I have a table called TAB1 which is updated daily by a job called SAJ1. I need a query to extract this information.
You can start with this select if the job step in T-SQL then it will find the text what you will declare as table name.
use msdb
Declare #table_name varchar(50)
set #table_name='Test'
select j.name,js.command from dbo.sysjobs j
inner join
dbo.sysjobsteps js
on j.job_id=js.job_id
where command like '%'+#table_name+'%'
One of the options available is the table msdb.dbo.sysjobsteps that enlists all the jobs and their steps. You can go into the Command column of the output and look for required information.
select * from msdb.dbo.sysjobsteps;
I wanted to move log datas that have a specific user_id to a new table on Redshift. I've started playing with WITH block like :
WITH moved_rows AS (
DELETE FROM sensor_log_enable
USING sensor_log_disable
WHERE sensor_log_enable.user_id
IN (16,17,18)
RETURNING sensor_log_enable.*
)
INSERT INTO sensor_log_disable
SELECT * FROM moved_rows;
But redshift doesn't like it.
ERROR: syntax error at or near "DELETE"
LINE 2: DELETE FROM active_connections
Redshift doesn't seem to include DELETE in WITH block. What's the best strategy then ?
1 INSERT INTO then an INNER JOIN OR LEFT OUTER JOIN with DELETE?
To 'move' data between tables, you must:
Use INSERT INTO to copy the data to the target table
Use DELETE to delete the data from the source table
They must be performed as separate SQL commands. You can, however, wrap those commands in BEGIN/END statements to commit them as one transaction:
BEGIN;
INSERT INTO...;
DELETE FROM...;
END;
I need to delete and append the data from a Access Table ULAE. I want to create a parameter query where parameter needs to be picked from another table LAE.
This table has 3 columns(Group,le,qtr) that will be an input and will be part of where condition.
I am trying to run the query:
DELETE FROM t_00_unearned_unincepted_alloc_basis_table as ULAE
INNER JOIN [Table Valued Parameter] as LAE
ON LAE.le=ULAE.le;
It shows the error that specify the input table you want to delete.
Thanks in advance.
Try like this
DELETE ULAE.*
FROM t_00_unearned_unincepted_alloc_basis_table as ULAE
WHERE ULAE.le IN (SELECT le FROM LAE where le= parametervalue)
I have the following query in SQLRPGLE for DB2:
INSERT INTO ITEMS2 (PROGRAM, VLDFILE, VLDFLD,
SELFILE, SELFLD) VALUES(:SCAPP , 'CSTMR', 'CYC',
'BYC', 'BYCC');
I would like this query to be run in 2 libraries as in FIRST/ITEMS2 and SECOND/ITEMS2
where FIRST and SECOND are the library names. Can this be achieved in one query?
For those who have no understanding of iSeries: The above insert statement would be similar to having a insert query for 2 tables.
The INSERT statement does not support inserting into multiple tables.
However you could create a trigger on FIRST/ITEMS2 to automatically insert/update/delete the record into SECOND/ITEMS2.
See the CREATE TRIGGER statement for more information.
If this will be run often, consider making the INSERT into a stored procedure, and then setting the target schema via SET SCHEMA:
set schema=first;
call my_insert_proc(:scapp);
set schema=second;
call my_insert_proc(:scapp);
You could create a QMQuery like this
INSERT INTO &LIB/ITEMS2
(PROGRAM, VLDFILE, VLDFLD, SELFILE, SELFLD)
VALUES (&SCAPP, 'CSTMR', 'CYC', 'BYC', 'BYCC');
Then
STRQMQRY myQmQry SETVAR(('LIB' 'FIRSTLIB')('SCAPP' &VAR))
STRQMQRY myQmQry SETVAR(('LIB' 'SECONDLIB')('SCAPP' &VAR))
From IBM's Syntax diagram of INSERT ( http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Fdb2%2Frbafzbackup.htm ), I'd say you have to go with two queries.
But after the first time of executing this query, you can try changing the current library ( http://publib.boulder.ibm.com/infocenter/iadthelp/v7r1/topic/com.ibm.etools.iseries.langref2.doc/chglibl.html ).