I am looking for a way to connect a tuple of values with a random UUID in a non-locking manner and without the potential to fail a transaction due to concurrency constraints. The table I need to …
Tag: sql
Replace chars in string if it starts or ends with specified char
I have a column in my database with entries that starts or ends with a hyphen. I would like to find these rows and remove/replace the hyphens if it’s the last or first (or both) char in the string. …
Teradata locks table for read while accessing to table through view with access rights
This is really weird. I have 2 view, one with access rights and other with read rights to table. replace view v1_read as locking row for read select id1 from t1; replace view v2_access as locking …
sql query to fetch exchange rate
Given a sales table with sales amount stored in local currencies and an exchange rate table containing currency conversion rate, to get total sales amount in USD for each sales date I need query Sales Table: Exchange Rate Table: have no idea how I should proceed I have to do two things match the currency and …
Max Value based on two columns
I have a table with multiple columns that contains both month and year. I’m trying to identify based on column1,column2 what is the greatest month and year. I have a DDL for a test table as such. This is the data in the example table. I want to get the record with the max month and year. When I attempt
How to verify SqlAlchemy engine object
I can declare engine object with the invalid username, password or address and get no exception or error: it prints likes it is a valid engine object: What would be a common way to verify (to check) if the engine object is valid or if it is “connectable” to db? Answer Question: How to verify if th…
Mysql Sum daily totals into weekly totals for given date range
Currently my db table has dailTotal values for every single day, I need to get these grouped into weekly totals. Is it possible to add the daily totals up into weekly totals and display a row each weekly total between the given date range. Im not quite sure where to start with this one. My current query to ge…
Using ‘LIKE’ and ‘REGEXP’ in a SQL query
I’m trying to use some regex on an expression where I have two conditions on the WHERE clause. The pattern I want to capture is 106 followed by any digit followed by a digit that must be either 3 or 4, i.e. 106[0-9][3-4] First, I tried this: This produced an error as below and it would be good to know
CONVERT issue in sqlserver with Msg 529 error
This statement is giving me a error VALUE column Datatype is TEXT in the RESULTS table. How can i overcome the above problem. please help ! Answer You can’t convert from text to datetime You must apply two convert operations. The first: From text to varchar The second: From varchar to datetime So your q…
How to get datasource from Connectionstring using PowerShell?
In .Net we can get the datasource from a connectionstring using below mechanism: I was trying to do that in PowerShell but getting the following exception: New-Object : Exception calling “.ctor” with “1” argument(s): “Keyword not supported: ‘metadata’.” At line:…