I need to TRUNCATE or DELETE all tables in schema. I found this code: but on AdventureWorks it gives me: So I found this alternative code: But the result is the same: How to TRUNCATE or DELETE all tables in schema? Answer You simply need to wrap your “delete from all the tables” script with a R…
Tag: sql
How to combine information from a main table and a log table in SQL Server
I currently have 2 tables in my database that i need to combine information from. One of them is a log table, that registers the status change of all products in the system. Structure example: ChangeDate Product LastStatus NewStatus 2021-10-01 A New Aging 2021-11-02 A Aging Ressuply 2021-11-25 A Ressuply OFF …
Query did not return a unique result
This is the query I have written: This is the output I am getting from the database: id versions 101 0.0 101 1.0 101 2.0 101 3.0 In my application, I am storing this result in but it gives an error saying “query did not return a unique result” How can I store this result? which data structure coul…
Count all the entity between periods – SQL Server
I want to count all the entities that created between August 1 until May 31 for each year. (academic year) I am successful counting it monthly, but it’s not good enough: Can someone help me with this? Thanks. Answer you can try this : Explanation : when the month is small than 6 then it’s part of …
SQL: Substring until second character starting from right keeping left values
I have this filename AAAA_BBBBB_CC_HDDD_HGGG.csv and I’m trying to keep the values after the second underscore starting from the right. So i want to keep any values just before _HDDD_HGGG.csv This is my code: And this is the returned value: Instead of being AAAA_BBBBB_CC. Does anyone has a clue for this…
Data query to keep the common data
I have a table Table 1 : It the final table contains all data . ID and IDS are composite key table 2 : Its a pre final table which will upcoming data with incomplete information EXPECTED RESULT : Some IDs (ID+IDS) are in Table 1 and some are in Table 2 . I need to compare the data of
Hive trunc date format issues
I am trying to convert GP to Hive migration logic but below statement giving the wrong output while execute query: output for GP : 2021-12-31 similar if we converted Hive query out put if Hive query : 2022-01-02 i could see the difference of the date. please help me. Thanks Answer You are subtracting interval…
DB2 LUW MERGE using same table to update a different row
My table data looks like this My poorly attempted SQL is this… It is updating all rows in the table. I do not want this. How can I make it ONLY update the 1 latest PRINTED row which has an empty PDF_FILE ? Answer The idea is to enumerate target rows and update only the 1-st one.
Aggregate function of column that has at least one type of value in a different column
I have table below as How can I query my table above to get average of only my IDs that have at least have one row with blood type of A Expected output: Thanks! Answer Tim’s answer is good, a simpler albeit perhaps not how you would want to do it, other way, is doing HAVING in long form so
Does Apache Ignite really need to use the very old version of sqlline which has issues & missing certain features?
I see that Apache Ignite (and the GG editions for that matter) uses a very old version of sqlline which has issues & missing certain features. The version used is 1.3.0 which is from 2017, whereas the latest version is 1.12.0. The reason this comes up is because the old version being used in Ignite has ce…