I have some specific values I want to extract out of a string in SQL Server, but I’m not sure exactly how to get it done with PATINDEX. Take this string: declare @Command nvarchar(500) = ‘IF dbo….
Tag: sql-server
How do I get the most recent processdate in a group?
I’m wanting to get the most recent entry per month using acct.processdate. I’ve tried using the MAX() function, but it doesn’t help since I am using group by. How do I go about doing this? DECLARE @…
Grouping the rows by similarities
I am working on SQL server. I have the following table: For each BIGroup I have a multiple VarianceName. For each VarianceName I have multiple PartNumbers. I am comparing every partnumber with the …
How to get the primacy of a function for an employee?
I have this following query to get all the functions and the related scopes (companies) for an employee : SELECT * FROM employee_scope WHERE EmployeeId=54 Output : EmployeeId FunctionId …
How setting Auto Commit off, helps to start a transaction in JDBC?
Many articles and documents says that by setting Auto Commit off, You can start a transaction in JDBC. This Topic also ask same question but It doesn’t answer to the question and just said: …
How do I join a sparse table and fill rows between in SQL Server
How can I apply weights from a one table to another [Port] where the weight table has sparse dates? [Port] table [Weights] table So, I want to use the weights as if I had a full table like this below. i.e. change to new weight on first day it appears in [Weights] table: Answer You can use apply: outer apply
Is there a way to split text from cell into multiple records in SQL using line break delimiter?
I have a system generated report that exports all expense reports for a given period. All employees attached to the report are exported in one field “Attendees”, separating multiple employees with line breaks. I would like to break the cell into multiple records, still including the expense report…
Conditional join on soonest date – SQL Server 2017
I am working with two tables: tblOrders and tblPOs I am trying to join these two tables, and for each order, select the PO with the earliest arrival date (in the event there is more than one). So for Order Number 10244, it has two POs, PO99455 and PO99456. I would want PO99456 to be associated, since it’…
Condition on SQL Server query
The below SQL query is in a SQL Server 2017. I want when the value of UtenteCliente.CostoFatturazionePersonalizzato is 0 or null is configured with the value of Utente.CostoFatturazione, to do this I use the query below but the result always returns null. How can I do this? SQL Query: Answer You can use CASE …
selecting a variable string name in sql select query in case of stored procedures
Suppose I want to select a constant value in an sql query, I could do something like this : select name,age,’tick’ from tableA I want to dynamically generating an sql query using stored procedures. …