1,171 questions
Best practices
0
votes
1
replies
80
views
Security implications of SQL Server ALTER ANY EVENT SESSION permission
This is for SQL Server 2019.
I want to give our developers the ability to create, manage, and view extended event sessions (without granting sysadmin). This can be done by granting ALTER ANY EVENT ...
Score of 0
0 answers
84 views
How do I programmatically drop a generated DEFAULT constraint? [duplicate]
I created a table in a script where one of the columns was established as such:
CREATE TABLE [schema].[table](
[ColumnName] [int] DEFAULT 45);
This will randomly generate a constraint like so: ...
Score of 3
4 answers
154 views
Calculate the percentage of ids with at least one record in a given group from a different table
I have three tables in a SQL Server 2019 database. A Users table with a list of user IDs, a WebApps table with a list of applications, and WepAppAuditLogs with a log of when users accessed a specific ...
Score of 9
1 answer
446 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 ...
Score of 3
1 answer
142 views
Get table name of the columns, used only in select statement of the view
Suppose the following is the select statement of a view
SELECT Emp.ID, Emp.FullName, Emp.JoiningDate, Dept.DepartmentName, Reg.RegionName
FROM Employees AS Emp
INNER JOIN Departments AS Dept
...
Score of 0
1 answer
201 views
Windowing functions lead, last_value, get second to last
I've got a table that's basically a movement graph, e.g.
CREATE TABLE MoveGraph
(
Start varchar(10),
End varchar(10),
UpdateDate smalldatetime
)
Problem is I want to know the ultimate ...
Score of 5
2 answers
247 views
Are there some ways to instruct EF Core to generate query in a particular way?
I understand that the main purpose of EF Core is to let the developer work with a database without paying attention to all the specifics of database programing, and let him just work with plain .NET ...
Score of -3
1 answer
152 views
Merge Rows into single column
I have a table in below format .
I am trying to merge columns and convert into row.
I tried doing that using PIVOT but it is taking column as entry and not allowing me to pass values.
Here is my ...
Score of 1
2 answers
181 views
Combine Multiple Tables into Single Resultset
I have 4 tables with data shown here in SQL Server 2019 (RTM) -15.0.2005
Table 1: Buyer
ID
NAME
123
ABC
234
XYZ
456
MNO
Table 2: Sell Detail
Sl No
ID
TYPEID
A
123
1
B
123
2
C
123
3`
D
234
1
E
456
2
...
Score of 2
2 answers
270 views
Join on one column and if null join another column
I need some help handling null columns in joins. I have three tables (below are just examples) Map, Employee and Region. Primary table is Map where I join Employee table on the MapID column to get ...
Score of 2
2 answers
103 views
Query on SSRS Content table for reports with hyperlink action returns all reports
I am trying to identify only reports with a hyperlink to another report. I am using SQL Server 2019 (150).
My SQL:
SELECT
C.ItemID,
C.Name AS ReportName,
C.Path AS ReportPath,
CONVERT(...
Score of 1
2 answers
148 views
Pivot multiple columns [duplicate]
I have a vertical table that end users want converted to a horizontal table with some groupings. I'm writing this in SQL Server 2019.
My table looks like this:
PKID
cID
vID
vDate
1
2
81
1996-04-04
2
...
Score of 0
1 answer
215 views
JSON column mapping – navigation property throws NullReferenceException
I have a model with a WorkFlow column in the database, defined as nvarchar(MAX) and storing JSON data. Previously, we treated it as a plain string in our C# entity, but I'm now trying to take ...
Score of 6
2 answers
176 views
Parse multiple JSON items from a table cell
My table in SQL Server with an nvarchar(max) column holds multiple JSON arrays in each cell. I am trying to parse the 'result' items into separate rows.
JSON array:
[
{"successful":true,
...
Score of 2
3 answers
161 views
Query count & sum nested selects into a Grouped Category
My current project/issue is we have a list of permit types. With these types they are needing to be grouped by an overall category. Once grouped out the end goal is to count how many within specified ...