Right function with character and integer

I have a SELECT statement where I need to compare the month of a date field to the 2 left characters in a VarChar field. I can’t seem to figure out how to do this. So I broke the 2 pieces out and ran the following code (I simplified it by removing fields irrelevant to… Read More Right function with character and integer

How to read an XML data in sql server?

I have an XML <Table> <Columns> <Column Name=’Name’ Datatype=’varchar(100)’/> </Columns> <Rows> <Row Name=’Test’ Number=’123’/> </Rows> </Table> I want to read Name value in the provided xml in sql server How Can I do that? I tried using `Declare @XMl XML select @xml= cast(Data as xml) from Table select y.value(‘Name[1]’,’varchar(100)’) as Name @xml.nodes(//Row) as x(y)` but… Read More How to read an XML data in sql server?

Compare multiple differences in SQL query

Currently I use this query to show the differences: SELECT CASE WHEN PaymentMethodCRM <> PaymentMethodBOU THEN ‘Payement Method CRM / BOU’ WHEN PaymentMethodCRM <> PaymentMethodFicheERP THEN ‘Payement Method CRM / ERP’ WHEN PaymentDeadlineCRM <> PaymentDeadlineBOU THEN ‘Payment Deadline CRM / BOU’ WHEN PaymentDeadlineCRM <> PaymentDeadlineFicheERP THEN ‘Payment Deadline CRM / ERP’ WHEN EditModeBOU <> EditModeContratERP… Read More Compare multiple differences in SQL query

Update the Indicator column based upon the Id Column by Incrementing of 5 numbers

I have a table with Id, Site_Name, MEMSUB and Indictaor columns… now my requirement is to update the Indicator column based upon the Id Column Below is my table, Id Site_Name MEMSUB Indicator 1 OEB 503280476 1 2 OEB 801730793 1 3 OEB 805152312 1 4 OEB 815049353 1 5 OEB 830205279 1 6 OEB… Read More Update the Indicator column based upon the Id Column by Incrementing of 5 numbers

Convert coluumn to multiple rows usind mssql

create table: Create table StudesntMarkList(StudentID int , StudentName varchar(100), Performance varchar(100), class varchar(100), Section varchar(100), subject1 varchar(100), subjectmark1 varchar(100), subject2 varchar(100), subjectmark2 varchar(100), subject3 varchar(100), subjectmark3 varchar(100), subject4 varchar(100), subjectmark4 varchar(100), subject5 varchar(100), subjectmark5 varchar(100), subject6 varchar(100), subjectmark6 varchar(100)) Insert Value: insert into StudesntMarkList values(1, ‘shiva’, ‘not bad’,’10th’,’C’,’science’,58,’social’,”,’english’,70,’maths’,”,’biology’,67,”,58) I have a table that looks like… Read More Convert coluumn to multiple rows usind mssql

JSON_QUERY with Column values

One of my tables contains JSON values in each row of a column. The data is as below (example. one row) [{"id":"30a66bec-c0aa-4655-a8ef-506e52bfcc14","type":"nps","value":"promoter","decimalValue":"10"},{"id":"37850b3b-1eac-4921-ae22-b2f6d2450897","type":"sentiment","value":"positive","decimalValue":"0.990000009536743"}] Now I’m trying to retrieve two columns from it. (id, value) I’m writing the below query using JSON_VALUE but getting NULL values in each row of the new column. select a.jsondata,JSON_VALUE(a.jsondata,’$.id’) from table… Read More JSON_QUERY with Column values

SQL query – tracking which rows in an interrupted sequence are related to eachother

I have a table consisting of actions that are logged when users are viewing files. When a user views a file, this can result in multiple actions over time. As multiple users can be active at the same time, their actions can become intertwined. I am looking to create an additional column in my query… Read More SQL query – tracking which rows in an interrupted sequence are related to eachother