Skip to content
Advertisement

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 contents without losing any data. Here

Using JSON_VALUE for parse column in SQL Server table

I have never worked with JSON in SQL Server before that’s why need some help. I have written a simple snippet of code: In sample above I write code how get first “id” from “tags”. But how looks like script if in “tags” not 2 “id”, but an unknown number this “id” and result should be in column like this:

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 some data). Answer It

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 your sp_executesql execution

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 are reference to columns. I wasn’t able to find relevant

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 should be dynamic because

Advertisement