how to check if I created a stream successfully in TDengine - sql

I created a stream with the following statement:
create stream device_running_s trigger WINDOW_CLOSE watermark 60m into device_running as select tbname,wcs_sx_runing,_wstart,_wend,_wduration from point partition by tbname state_window(wcs_sx_runing);
The output seems ok.
Query OK, 0 of 0 rows affected (0.084000s)
However, when I execute a query on this stream, it failed.
taos> select * from device_running;
DB error: Fail to get table info, error: Invalid value in client (0.240000s)
I can't be sure if the stream was created successfully. Is there any way to check it?

Related

Unable to drop or truncate sql server table

We are using azure data flows and we are trying to load the data in one particular table in sql server. however our data flow keeps running for hours for smaller set of data.
when we tried to truncate or drop the table, our request times out.
how can we force drop and recreate the table.
What I checked
We don't have any foreign constraints that may avoid the drop
Getting this error when i tried to truncate
Failed to execute query. Error: A severe error occurred on the current command. The results, if any, should be discarded.
I also ran this query and found this
Query -
SELECT session_id
,blocking_session_id
,wait_time
,wait_type
,last_wait_type
,wait_resource
,transaction_isolation_level
,lock_timeout
FROM sys.dm_exec_requests
WHERE blocking_session_id <> 0
Is this causing the issue
How can I fix this issue
i found this after running
exec sp_who 88
What can i do on it
find out more about blocking session 88 , run exec sp_who 88 , seems like this is the session that is blocking , find out more about blocking stuff , if you are allowed to add a proc to the database , go get and install sp_whoisactive which gives you more information
then you can run : dbcc inputnuffer(88) to find out which main proc or process is executing that select query.
if this is safe to kill that process, you can kill that session by
kill 88
before killing that session make sure that session id is still running the same process

SAS - Insert statement into existing SQL table

Here is my code:
PROC SQL;
connect to odbc (dsn=ODC uid=sa pwd=XXXXX);
EXECUTE ( INSERT INTO dbo.tblDLA_Backup SELECT * FROM &dlafile.) BY ODBC;
disconnect from odbc;
quit;
Im getting this error
ERROR: CLI execute error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'work.dlabackup'.
If i do this:
proc sql;
connect to odbc (dsn=ODC uid=sa pwd=XXXXX);
insert into tblDLA_Backup SELECT * FROM WORK.DLABACKUP;
disconnect from odbc;
quit;
I get this error:
ERROR: File WORK.TBLDLA_BACKUP.DATA does not exist.
Why is it that I can't reference my SAS dataset and just insert? it should be simple as that..
The first error occurs because you are executing an SQL instruction on SQL Server, and not locally. And since this instruction contains a reference to your local SAS dataset, an error occurs because SQL server thinks it is a table in its own database.
You take a wrong approach on that one.
Your second approach is correct because you are executing the SQL in SAS, which both knows the local dataset and the SQL server tables. And it is syntactically valid at first glance.
The error is clear: SAS doesn't found the local dataset WORK.TBLDLA_BACKUP
Thus, verify if this dataset exists and is not corrupted:
in your explorer window, click on Libraries, then Work, and verify if TBLDLA_BACKUP is there, and if yes open it and check if you see your data.
I can't say more at this point, but you should hopefully discover something.
You need to use libref it you want to write into the foreign database.
libname sqldb odbc dsn=ODC uid=sa pwd=XXXXX ;
PROC SQL;
INSERT INTO SQLDB.tblDLA_Backup SELECT * FROM &dlafile.;
quit;
Note that you also need fix it so that your macro variable contains the name of a table that exists.

Copy Table from a Server and Insert into another Server: What is wrong with this T-SQL query?

I am using SQL Server 2014. I have created the following T-SQL query which I uploaded to my local SQL server to run as a job process on a daily basis at a specific time. However, I noticed that it failed to run. If I run it manually in SSMS, it runs correctly.
What is preventing the query to run as an automated process? Is it a syntax issue?
USE MyDatabase
GO
DELETE FROM ExchangeRate -- STEP 1
;WITH MAINQUERY_CTE AS ( --STEP 2
SELECT *
FROM (
SELECT *
FROM [178.25.0.20].HMS_ARL.dbo.ExchangeRate
) q
)
INSERT INTO ExchangeRate --STEP 3
SELECT *
FROM MAINQUERY_CTE
Basically, the function of the query is to copy a table named ExchangeRate from the live server and paste its content in a table of the same name (which already exists on my local server).
Error Log shows the following message:
Description: Executing the query "USE MyDatabase DELETE FROM
ExchangeRate..." failed with the following error: "Access to the
remote server is denied because no login-mapping exists.". Possible
failure reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly. End Error DTExec: The package execution returned
DTSER_FAILURE (1). Started: 10:59:30 AM Finished: 10:59:30 AM
Elapsed: 0.422 seconds. The package execution failed. NOTE: The
step was retried the requested number of times (3) without succeeding.
The step failed.
May be you have to create Linked Server in your local server to the Remote server?

How to Truncate Multiple Table in SSIS ( using ADO.NET Destination and Oracle Database)

I got a little trouble in SSIS. I have multiple table and i want adding Truncate statement so that table can't create double data.
This is the image of package that I made :
each Data Flow, i used Flat File Source and ADO NET Destination.
And then, in Execute SQL Task i want to apply Truncate Table
After that, i have error message :
"[Execute SQL Task] Error: Executing the query "truncate table Table1
truncate table Tabl..." failed with the following error: "ERROR
[HY000] [Oracle][ODBC][Ora]ORA-00911: invalid character". Possible
failure reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly."
What i must suppose to do?
P.S
Sorry if my english is not good
Since the destination is an Oracle Database you should use this syntax:
begin
execute immediate 'truncate table t1';
execute immediate 'truncate table t2';
end;
Does this syntax work:
truncate table table1;
truncate table table2;
Note the semi colons.

Not able to create Materialized query on AS400

I get an error message when trying to create materialized query in as400
I use winSql for the connection.
The syntax seems valid.
Could you please point out what am I doing wrong?
This is the statement I am trying to execute
CREATE TABLE AAA.TEST_MQ AS
(
SELECT test.*
FROM
AAA.TABLE_NAME test
) REFRESH DEFERRED
This is the error message:
Error: SQL0104 - Token <END-OF-STATEMENT> was not valid. Valid tokens: IMMEDIATE <IDENTIFIER>. (State:37000, Native Code: FFFFFF98)
I Tried creating an immediate one as well.
Try this:
CREATE TABLE AAA.TEST_MQ AS (
SELECT test.*
FROM
AAA.TABLE_NAME test )
DATA INITIALLY DEFERRED
REFRESH DEFERRED
MAINTAINED BY USER
ENABLE QUERY OPTIMIZATION
;
I use JaySQL Lite and it works.