All Questions
Tagged with sql sql-server
150,489
questions
0
votes
0
answers
52
views
Get the no.of records Inserted in last 10 days
In my table I didn't have primary key and forgot to add timestamp column. Now I would need to find the records with date time of insertion in last 10 days. Is there a way to find this? If yes then how?...
-3
votes
0
answers
52
views
Why am I getting the wrong value or NULL after doing left joins? [closed]
I have a table called Persons with an ID column. I have another table called Cases which has an ID, another PersonID, and the date that the case was made. I have a third table called PersonsCases, ...
-1
votes
0
answers
50
views
Improve performance or change query so it can be an indexed view
We have this query in a non-indexed view in SQL Server 2022.
It's used everywhere and I'm trying to improve the performance. A lot of queries we use elsewhere join to it.
My thought was whether there'...
-4
votes
0
answers
32
views
Validating rules [closed]
I've a table data:ORG ER |ACT | BUD N |ACT N_1
I identify the cases where I need to identify the ORG ER which will be rejected and I need to insert it in a table of reject.
Here the rule 1 that ...
0
votes
1
answer
41
views
Get all hierarchy in SQL Server
I have a table like this:
ID_employee
ID_Manager
1
1
2
1
3
1
4
2
5
3
6
5
7
5
8
5
(1 is a boss)
What I would like is a result like:
ID_employee
ID_Manager
8
5
8
3
8
1
7
5
7
3
7
1
6
5
...
0
votes
1
answer
55
views
Query between two dates gives incorrect results in SQL Server? [closed]
Im trying:
SELECT *
FROM database a
WHERE Applicant_End_date >= '2024-01-01'
AND Applicant_Start_date <= '2024-06-30';
Results:
Applicant_End_date shows results starting at 2024-01-01 like:
...
-1
votes
0
answers
44
views
SQL query to return the MAX(CreateDate) from tables that are returned in the initial result set?
Working on a SQL Server Management Studio query. The goal is to return the MAX(CreateDate) and table names from a query that returns a set of values from a column called WhenSQL. Each table has its ...
-1
votes
1
answer
58
views
SQL JOIN to the same table explanation
I am refactoring some code that was written by another person that is no longer around. In this query a MAX(Date) is being selected, but then joined to they same table via MAX(Locator). The locator is ...
0
votes
1
answer
66
views
WITH (NOLOCK) /SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED on stagnant data [duplicate]
I will prefix this by saying I may be misunderstanding / misinterpreting something here!
Our IT dept requests we update queries / stored procedures to use NO LOCK. I need to add that to every stored ...
0
votes
0
answers
32
views
Is there a way to summarize individual totals under one category? [duplicate]
I am supposed to create an SQL query that determines the total hours of certain projects from two tables, totals them per month and lists them.
I've got these tables:
Table "A"
ID
Name
1
...
0
votes
0
answers
58
views
Issue with connection to SQL Server from remote network [closed]
Introductory data:
SQL Server 12.0.6329 (read-only rights)
SQL Server Management Studio on the server machine
The server is located in a local network behind a router
Router with a white IP address
...
0
votes
1
answer
29
views
SSRS 2014 date range parameters not working with an OR clause
I have a query in SSRS 2014 that has an OR clause between a date range parameter and a like parameter.
The date ranges are nullable as well as the like parameter.
The problem I am having is the data ...
0
votes
1
answer
80
views
COMMIT TRAN not working in SQL Server 2019
I am working in an environment where I run the code below and SSMS says that the command was executed successfully. However, when I try to close the window it says that I have uncommitted transactions....
0
votes
1
answer
42
views
Conversion failed when converting the nvarchar value to data type int while inserting records into table
I am using a script to automatically update a database daily to sync Azure Blob Storage with a queryable Azure SQL Server database. Among deleting and updating records, I will insert brand new records ...
0
votes
2
answers
53
views
How to split a column into 2 different columns with condition
I have this data about brands and sellers.
Brand
BB_seller
Biotherm
Amazon
BVLGARI
3rd Party
BVLGARI
3rd Party
Carolina Herrera
Amazon
Chanel
Amazon
Chanel
Amazon
select Brand, substring([Buy ...