I've been trying to find a way to decode a base64 column in a bigquery table to a GUID/UUID. Does anyone know of a function in SQL that I can do this with or would I have to use a different language than SQL.
If understand correctly, SELECT FROM_BASE64(guid_column) AS id should do it for you.
Related
I wish to create a table using edit text. The reason that I don't use auto detect is that my date format is not in the US format and Bigquery doesn't understand it (I'm not sure if it is a bug or I'm missing something). When I use Auto detect, Bigquery reads the date as mm/dd/yyyy while my date format is dd/mm/yyy.
I've tried the below but I'm getting an error
State:string,
New_Existing:string,
PARSE_DATE('%d/%m/%Y', Prd_Dt):DATE
You can use JSON to write your schema using edit text, refer to this GCP Documentation. Using your scenario below this is how we applied it to JSON:
Output:
However, you can only use the PARSE_DATE function in Bigquery when doing DML statements such as SELECT as per this GCP Documentation.
I would like to convert a blob of an oracle db to an readable string.
I have tried some functions, but none of them worked for me.
In the end I tried to convert the string via sql statement like:
SELECT CONVERT(CAST(blob as BINARY) USING utf8) as blob FROM tablewithblob
Can anyone tell me, what I am doing wrong? The error of the sqldeveloper is "missing right paranthesis. Thanks in advance!
The CONVERT(value USING charset) function is a mysql function, not Oracle
https://www.w3schools.com/sql/func_mysql_convert.asp
Take a look at this instead
https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions027.htm
But it looks like DBMS_LOB is a better way to do what you're doing in Oracle. Go check out How do I get textual contents from BLOB in Oracle SQL
I am trying to convert an Oracle query to a SQL Server and facing an issue. Can you please help me ?
Oracle Query:
select ORA_HASH(SYS_GUID()) as SEGMENTID from my_Table
I am looking for a function which is equivalent to ORA_HASH() function in SQL Server. I was searching in google and found that HASHBYTES() function is the one which works as ORA_HASH in SQL Server. But when I tried to use, the return value of this is Hexa decimal and on the other hand, ORA_HASH is returning an integer.
Can you please help me in proving the equivalent function to ORA_HASH in SQL Server which works same as ORA_HASH ?
You shall try CHECKSUM which as per doc is intended for use in building hash indexes. https://learn.microsoft.com/en-us/sql/t-sql/functions/checksum-transact-sql
I need to store binary data in single database field (DB is SQLite, it's important!). Binary data is a some one-dimensional array.One of the best way to do that is BLOB data insertion. As far as I know Matlab doesn't consist methods for BLOB data processing. How can I do that using Matlab environment? Maybe using raw SQL query?
In a raw SQLite query, a blob can be written as a x-prefixed string, with each byte representeded by a two-digit hexadecimal number:
INSERT INTO MyTable(BlobColumn) VALUES(x'0123AB');
To return a blob as text from a query, you can use the quote() function, which uses the same format:
SELECT quote(BlobColumn) FROM MyTable; --> returns the string "x'0123AB'"
It might be a better idea to use some other SQLite3 driver for Matlab, e.g., https://github.com/kyamagu/matlab-sqlite3-driver, http://jaewon.mine.nu/jaewon/2015/06/17/another-sqlite-interface-for-matlab/.
I have a MSSQL table with large number of alpha numeric codes. I have to verify these codes are within certain characters. How do I write a SQL in MSSQL? Any advice ?
Codes Table
JFBBB22 -> Valid
JBBYB33
AXBBB22 ->Invalid
LBBBB33
Code I am using in c# to validate..
Regex.IsMatch(code, "^[BCDFGHJKLMNPQRSTVWXZ123456789]*$").
WHERE code NOT LIKE '%[^BCDFGHJKLMNPQRSTVWXZ123456789]%'
You can do it like this:
select dbo.RegexMatch( N'123-45-6789', N'^\d{3}-\d{2}-\d{4}$' )
For the full documentation check The MSDN site for the official page