Skip to content
Advertisement

Tag: tsql

SQL Server: Update table based on JSON

I am trying to update rows in table based on JSON I have. JSON has the following structure: Table dbo.sensors has same structure + few more columns. To insert such JSON object, not array, into table, I would do it this way: So I have 2 questions: how to iterate over each element in JSON array and update each row

Extract string between double quotes in SQL

I have a string and I need to return the characters between the double quotes ‘((“Name 1” and “Name 2”) or “Name 3”) I need to return I have used the function below to split the string but I am getting the (( and the Or and AND etc .. which I don’t want and unfortunately I can’t be certain

insert xml data to table stored procedure sql server

I have xml in following format I want to insert them in table so the table should have 4 records in the example. columns are name and alias. How can I achive this using cursor or something else? What i have tried. In cursor for entity i try insert alias value,but only first alias is taken. Answer

Adding a new column with data

Below is my table: Now I want to add a new column called ‘Gender’ with values M,M,M,F in 4 rows respectively. I first added a new column using: Now I understand I can add data one by one by using: But how do I add all 4 data at once? Answer You don’t, unless there is some other piece of

Advertisement