Skip to content

Tag: sql-server

Return all values from objects using OPENJSON()

Here is my problem: My JSON may vary based on API response and there is no guarantee that “shortTitle”, for example, can be present in my JSON next time when there is a post request. I have to figure how to “loop” (if that’s the correct term) through JSON to get all fieldID and c…

Table “already exists” after dropping with if exists

I got a pretty complex SQL that finally forced me to use a temp table to work around. Essentially it looks like this: However, I get an error message saying an object with the name #MYTEMPTABLE already exists in the database after a call with an error (which is rather likely if the customer/tester screws up s…

Like in dynamic function

The code below works well. I however have issues trying to turn it into a like statement that I need some assistance with So far, I have tried the code below but with not much success I have also tried; Answer If your stored procedure parameter is @deliverer and your dynamic SQL parameter is @pt, I believe yo…

SQL Server ‘AS’ alias unexpected syntax

I’ve come across following T-SQL today: that yields following result: The part that got me confused was d(c) While trying to understand what’s going on I’ve modified T-SQL into: which yields following result: It was clear that d & m are table reference while letters in brackets c & b…

Remove String and Symbols

I am trying to create a query to remove some varchar and symbols from a big string, basically a table will have a column with this format(the information comes from an API call): so the requirement is to take the main “column names” from the sample, so at the end the string will be like: this shou…