Skip to content

Tag: tsql

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

T-SQL : Alter Database statement inside IF is failing

We have a scenario where we have to change database compatibility based on SQL Server version and we have written below condition for the same. In one of our customer’s server this code is failing with below error and the server has SQL Server 2014 Msg 15048, Level 16, State 1, Line 4 Valid values of the database compatibility level

How to get NULL or Zero values in SQL Server results set

Trying to get the output of all mentioned accounts(total of 9) even though there are no existing records for the GB.periode = 11 Tried using ISNULL(SUM(GB.bdr_val), 0) but still I’m only getting output for GB.reknr = 5210 OR GB.reknr = 5211 OR GB.reknr = 5250 OR GB.reknr = 5340. I have a sample DB layout below, I still need the

Finding who called who

I have these two tables. Subscriber table contains SubscriberID and his Phone number. NetworkP2P contents SubscriberID, to who he has called AddresseeNumber and when the call started, ended. Example data: Subscriber NetworkP2P Not all Phone numbers match the ones that Subscribers have. How would I approach this, if I wish to have which outputs subscribers who have been in contact

Difference between delete statements

vs. Answer The logical conditions of the two statements are different. The first statement will delete any row in TableA if both it’s Field1 and Field2 correspond to the equivalent columns of a row in TableB. The second statement will delete any row in TableA if the value of Field1 exists in Field1 of TableB, and the value of Field2

Best way to filter data for a given range

I need to find Claims from a given table having a procedure code between the range ‘Q5000’ and ‘Q5090’. I am able to write a function for Int codes but am not sure how to best deal with characters range in SQL Server? I can manually write all the codes and filter them but is there any way by which