Skip to content

SQL Server: Return a string in a specific format

In TSQL, I need to format a string in a predefined format. For eg: SNO STRING FORMAT OUTPUT 1 A5233GFCOP *XXXXX-XXXXX *A5233-GFCOP 2 K92374 /X-000XXXXX /K-00092374 3 H91543987 XXXXXXXXX H91543987 I am trying with FORMATMESSAGE() built in function. For ex: FORMATMESSAGE(‘*%s-%s’,’A5233′…

Parse text of json object key value postgresql

I have the following kind of objects maintained in a table column. I have tried parsing this object to get the value for this key “1075852262” which has this value “Event=”13″ Description=”(EMOVIES r8)”……….” The SQL I have written is: The resul…

Select node from xml nodes

there! there is a small xml. I’m selecting data via And result like this But, need to have one more column with the contents of the entire row, like this Answer Use the query method cc type is XML. db<>fiddle

SQL convert rows to one Column

I have a table, Output before pivoting: Expected output: How to do that for three or more rows but always with to one-row column? Answer You can use conditional aggregation: However, I might suggest that you if you want all values in a single row that you just use arrays: