336,539 questions
2 votes
2 answers
107 views
Return data between certain Hour values
I am trying to determine if it's possible to query for data between two defined HOUR values from a DateTime value, instead of writing out each DateTime iteration. This need is to find matching values ...
1 vote
2 answers
139 views
XML format from SQL data table
I need to build the following XML data structure. I get the XML structure that I need but I am missing the student tag. <users> <user> <id>123</id> <name&...
0 votes
0 answers
67 views
SSMS Creating Keyboard Shortcut for Edit.Comment works, but Edit.Uncomment does not with same config [closed]
CTRL+G works: CTRL+B doesn't work: I've created a custom keyboard shortcut for Edit.Comment that works using CTRL+G. I used the same configuration for Edit.Uncomment using CTRL+B which is not ...
Advice
1 vote
9 replies
104 views
Does flipping from/to dates within date index make it more selective for SQL Server
In one of my projects I have an entity with startDate (from) and expiryDate (to): @Entity public class BlacklistedItem { //... @Column(nullable = false) private LocalDateTime startDate; @...
Tooling
0 votes
7 replies
104 views
How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?
I'm working on a .NET 8 application that uses SQL Server User-Defined Table Types (UDTT) to pass data to stored procedures. I have a situation where I need to ensure that my C# classes remain ...
0 votes
2 answers
98 views
Update query used the wrong table in the from statement
I accidently ran an incorrect and incomplete query on production as shown in the following. #TempDiff is a temp table with 2 columns as shown below. There are one or many [Pallet Contents] for each ...
Best practices
0 votes
5 replies
100 views
Alter a SQL Server table column size in production
What is the best way to alter a production SQL Server 18 table's column size, varchar(n +1). My understanding would be the following: Shut the website down to stop the transaction from coming in. ...
-2 votes
0 answers
61 views
Google Apps Script JDBC connection to SQL Server error: 'Failed to establish a connection to the database' [closed]
I had Google Apps Script directly connected to my server that has SQL Server through JDBC to synchronize Google Sheets data (read rows, insert/update SQL records) for free, but since Thursday, March ...
-3 votes
0 answers
79 views
SQL query validates in SSMS, but fails in SSRS [closed]
I'm writing a report in Visual Studio that throws the following error when I run it: Query execution failed for dataset 'MyDataset' Incorrect syntax near ','. The report's query checker can't parse ...
-3 votes
0 answers
92 views
Google Apps Script JDBC Azure SQL Server Connection Fails: "Failed to establish a database connection" Despite Correct Credentials [closed]
I'm trying to connect Google Apps Script directly to my remote Azure SQL server using JDBC to sync data from Google Sheets (read rows, insert/update records in Azure SQL) for free, but I keep getting ...
0 votes
0 answers
83 views
Error when creating EDMX from LocalDB .mdf in Visual Studio 2022
I am using Visual Studio 2022 and trying to work with internal .mdf databases (LocalDB) for testing purposes in an ASP.NET Web Forms project using Entity Framework (EDMX). Creating the database itself ...
0 votes
0 answers
21 views
Last backup, last copy, last restore are null in log shipping throgh view report log shipping [migrated]
I have made problem during configure log shipping on SQL Server 2019 standard version by missing last backup, last copies, last restore select not found on msdb. I have been using user AD all machine ...
Advice
0 votes
10 replies
111 views
SQL INSERT OUTPUT with more than two columns
I am processing a task of migrating a set of Customer records from a data source into our own production Customer database which is SQL Server. I have migrated the incoming Customer records into a ...
9 votes
1 answer
368 views
Selecting from a temporary #table whose column is sp_renamed has stopped working for SQL Server version 2019 and later
In a stored procedure (version 2019), renaming a column of a #table to a @value stops working for subsequent executions. The #table retains/gets the @value name of the very first execution. Is this an ...
2 votes
1 answer
100 views
Invoke-Sqlcmd times out after ~30s on some machines but not others (without -QueryTimeout). What determines the default and what’s best practice?
I'm testing client-side timeouts using PowerShell's Invoke-Sqlcmd: Invoke-Sqlcmd -Query "WAITFOR DELAY '00:00:31'" ` -Database master ` -ServerInstance $env:COMPUTERNAME Observed behavior: ...