I’m trying to print out xml results with a query in SQL Server 2014. The query is supposed return data from a date range, and return a concatenated list of player names and player times. The …
Tag: sql-server
SQL multiple rows calculate
I have a table in SQL Server and I am trying to calculate if a number is bigger than a selected row, but only if the rows that exist are greater than 1. I’ve looked online and looked into Union, …
Yesterday SQL Server
I know very little SQL and have been asked to fix a problem in existing code. The code is PHP but the SQL causing the problem is: $sql = “INSERT INTO Intranet.dbo.DailyBilling (Date, JobCode, SubJob,…
Select Subquery Group By
I am having an issue with this simple query. I get the error “Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, , >= or when the subquery is …
How is this code adding a number to a datetime without using DATEADD? [closed]
In the following SQL statement there’s some T-SQL that adds a number to a datetime and to a date: declare @t table(UserID int, StartDate datetime, EndDate date) insert @t select 1, ‘20110101’, ‘…
group by JSON Column that contains an array
I have the following table: that contains these data: How can I group by my array items in my JSON Column? and get this result:
Exclude weekends and public holiday for SQL datediff
this code works but seems like the results are off by 1 day Objective: Find the datediff for the two dates given. However, we will have to exclude Weekends Public Holiday Example The difference …
Select rows until running sum reaches specific value
I have the following data: DECLARE @t TABLE (usr VARCHAR(100), dt DATE, amount INT); INSERT INTO @t VALUES (‘a’, ‘2018-01-01’, 100), — 100 (‘a’, ‘2018-02-01’, 100), — 200 (‘a’, ‘2018-03-01’, 100), -…
Update a column using another column in the same table with two entries (Values) in SQL Server
I’m trying to update a column Product_Group from a column called Product in the same table. This Product column has two entries, Simple or Others. i.e shown below in Invoice table: The issue I’m have is that if you look at Top_Level ID 10, 19, 21 and 31 has multiple entries and the Product are mul…
Cannot insert the value NULL into column ‘ExampleID’
Upon executing I keep receiving the error: Cannot insert the value NULL into column ‘ExampleID’, table ‘DB_Example.dbo.tbl_Example’; column does not allow nulls. INSERT fails. However I don’t think any NULL values are present. I am trying to simply fill a table with specific valu…