Skip to main content
0 votes
1 answer
65 views

What are DATEFIRST's default values for non-US English languages in SQL Server?

SQL Server has a DATEFIRST setting that determines the first day of the week for date calculations. SELECT DATENAME(weekday, '2025-04-23') AS WeekdayName -- Wednesday SET DATEFIRST 7 -- Sunday ...
Stevoisiak's user avatar
  • 27.1k
1 vote
3 answers
95 views

Check if a datetime range overlaps business hours on specific days of the week in T-SQL

I have an SQL Server table Meeting with start and end times stored as a datetime. How can I retrieve records where the datetime range overlaps with company business hours. (IE: Monday to Friday, 9am ...
Stevoisiak's user avatar
  • 27.1k
0 votes
0 answers
58 views

Filter between two dates range [duplicate]

I am currently working with the data that has two dates parameter. I want to filter the data like this: If @p_date_from and @p_date_to NULL, then filter data between @p_date_invoice_from and @...
Annisa Indriani's user avatar
0 votes
0 answers
36 views

Replace records that contain only numbers from text field [closed]

I have a text field that should only contain company names. However, I am finding instances where some fields incorrectly contain only numbers. I would like to replace these instances with null. I ...
Frank's user avatar
  • 1
3 votes
2 answers
70 views

Using unique index to enforce strict order numbers (that are picked by users)

Can I enforce strict user-editable order numbers, either using a unique constraint or otherwise, in a way that enables my website users to reorder a list of n entries using at most n database writes? ...
Nitrox Tank's user avatar
0 votes
1 answer
47 views

T-SQL to parse nested json into temp table

I need to parse some JSON data coming in from a REST endpoint and insert it into a temp table in SQL Server. Everything is working fine up to the point of the nested childArray where it's not seeing ...
B. Youngman's user avatar
-2 votes
0 answers
77 views

Break while loop when a condition is met [closed]

The software I'm using is capable of sending a trigger on a user generated event. I'm trying to collect contextual data from one table in the db, and write it to a column in a different table. When ...
RobGD3's user avatar
  • 1
0 votes
1 answer
114 views

SQL replace function not working on strings more than 8000 characters

I'm stuck with the strange behavior while using SQL server replace(). I want to replace a string which is more than 10000 characters with space. The pattern string also more than 9000 character long. ...
Peter's user avatar
  • 121
-1 votes
0 answers
40 views

How to address nested JSON arrays? [duplicate]

Let's assume that this is absolutely valid JSON structure, representing nested (or multi-dimensional) array: Further assume we have a table in SQL Server with just two columns: the id INTEGER and ...
Petr Pivonka's user avatar
1 vote
3 answers
136 views

SQL Server select query where clause

Evaluating one side of OR in my query. I have a SQL Server query with 2 separate complex filters. The intention to combine them in one as follows: Declare @BoolSet Bit = 0 Select Distinct Top (1200) ...
mathias's user avatar
  • 21
1 vote
4 answers
113 views

Join a date table to a data table to get counts per year/month

Assume a table filled with dates from 2010 to 2050. Assume a data table (called Lease) with some data, and includes a date column, Move_Out_Date. The goal is to count the records with Move Out Dates ...
user1911400's user avatar
0 votes
1 answer
54 views

Delete (or Select) data with subquery using T-SQL

I am trying to come up with T-SQL query to delete data based on these conditions: Find data that have same Email. If that user has both AllLocations 'Yes' or 'No', delete entry/entries that are not ...
Java's user avatar
  • 1,304
-1 votes
1 answer
90 views

Using sp_executesql drop multiple tables

I’m trying to write a script to purge all the tables (and views and functions and procedures) from the current dbo schema in the current database. Bolting together what I have learned from other ...
Manngo's user avatar
  • 16.6k
0 votes
1 answer
57 views

Concat the first and last sequential line number with a hyphen

Our table stores the line numbers of an order. Is it possible to concat them into a string, where the first and last sequential lines are separated by a hyphen, and non-sequential lines are separated ...
Jack Morris's user avatar
0 votes
1 answer
94 views

Reuse the same set of columns for different tables

I have some .sql files that create SQL Server tables. Some of them have some of their columns in common. I'd like to create a CommonColumns.sql file which will be imported by the create table .sql ...
Potis23's user avatar
  • 526

15 30 50 per page
1
2 3 4 5
4910