Can you recommend a sql formatter?
Dear colleagues, Which SQL formatter would you recommend? In our organization, we have coding standards. My problem is, there are to many of them. As I am responsible for the repositories containing SQL, I want to enforce a single standard by…
SQL Server
Transact-SQL

Text and NVARCHAR are incompatible
Hi, I am trying to join 2 tables together but once column is a text, and the other nvarchar and as a result, I get the following error message Msg 402, Level 16, State 1, Line 101 The data types text and nvarchar are incompatible in the equal to…
SQL Server
Transact-SQL
Best Practice to Decide Partition Table in SQL Server
Hi All, We have a database on SQL server with a large size (about 20 TB) and we plan to partition the existing tables in the database. but we are still confused to determine whether to partition the table, whether it should be partitioned…
SQL Server
SQL Server Analysis Services
Transact-SQL

How to delete Old database backup files from Azure blob container through Using T-SQL script without using any Azure CLI and PowerShell commands.
Here is the corrected version of your sentence: We are facing an issue with deleting old backup files from the Azure Blob container. Our company is not willing to spend money on this deletion activity. Please let me know how to delete old database…
Transact-SQL

how to calculate age from date of birth
im required to come up with a script for a solution where you need both peoples date of birth, and age, when registering them its clearly stated that the person wont be asked to input their age, just their dob. but the age is needed what needs to be…
Transact-SQL
iNLINE PIVOT QUERY SYNTAX ERROR
a PIVOT query runs without error on its own but gets a syntax query when made into an inline query
Transact-SQL
Unable to open the physical file. Operating system error 5: “5(Access is denied.)”
I am trying to work on a query to attach a database (UNC path) remotely. I have SQL Server management studio (SSMS) installed in SQL Server machine (machineSQL) and also in another machine (machineRemote) in same domain. Query:: CREATE DATABASE…
SQL Server
Transact-SQL
SQL server. Updated data is lost and reverted back to the past data
SQL SERVER. I have a database that works fine and saves the update of the data and i see that data updated, but after a possible week or month, I find that the data returns to its original position before the modification and the modification completely…
SQL Server
Transact-SQL
can the ROW_NUMBER() function be used without the PARTITION clause?
I'd like to get row numbers for my output without having to use ROW_NUMBER() OVER(PARTITION BY ...). Is this possible, and can you provide an example?
Transact-SQL

Last passoword updated/changed date and time in Azure SQL Database for sql logins
Hi Team, as part of compliance we are planning to generate report about when was the last time password changed/updated on all Azure sql database sql logins. Because each a every Azure SQL databases we found around 150 logins. Please provide any T-SQL
Transact-SQL
How to Delete top 1 item after using CTE (Common Table Expression)
I am trying to delete top 1* item after using CTE. I have the bottom T-SQL statement which works fine with select statement on the second part. with cte as ( select *, email_cnt = count(*) over (partition by "User"), …
Transact-SQL

sql query to recon data between 2 systems
--SQL query for getting data from 2 vendor systems --Hi All, --I get data from 2 vendor systems. I need to reconcile this data and match. I have very limited fields to compare DECLARE @vendor1 TABLE ( …
Transact-SQL

Stored procedure not sending out emails using sp_send_dbmail
Greetings again mates, The following stored proc performs several different tasks at once. At the top of the SP, the SELECT statement queries two tables (Employees and AuthorizedUsers) to pull names and email addresses of employees based on some WHERE…
SQL Server
Transact-SQL
XTP_THREAD_POOL- lot of spids running in background when no sql workload is there.
In our L&P systems, before the actual run kickoffs we have a SOP to run rebuild indices and update statistics job. Recently we are seeing SQL memory consumption is great than 80 % even after the above jobs get completed and there is no SQL workload…
SQL Server
Transact-SQL
SQL Server Update particular record in a table
DROP TABLE if exists #test create table #test ( PID int, Category varchar(100), status varchar(10) ) Insert into #test values (123,'Lessthan8','compliant'), (123,'greatherthan8','compliant'), (456,'Lessthan8','Missing'), …
Transact-SQL
cast float to numeric
Hi! I import transactions from a table where the amount column is set to Float and some values in the column is scientific numbers (example below). I need to Cast the float column to decimal values but i cant find any solution on how to do that. Is…
Transact-SQL
Group By and it's Highest Value using SQL Query
In the table below, how do I group by Unit and then get the highest value from Quantity of that group? I have put 21 in row 4 under HighestValue column since its the highest value among all records in Unit
Transact-SQL

Group By and Running Total and Totals using SQL Query
My sql query returns the following values. How do I Group By 2. Add Running Total 3. Add Total to get it done as shown in pictured example 1, 2 and 3 below? I need 3 queries to get the following results: 1: put it in Group By to…
Transact-SQL
get depends objects for ssis packages
I need to get list of objects depends in each SSIS package using SQL scripts or any other approach autoprocess. Example ssis solution have 2 packages. package1.dtsx package2.dtsx Package1.dtsx have 5 tasks and 2 are execute sql task and 3 are data flow…
Transact-SQL
changing the endcoding of an attached file in sql trasaction
Hi, I have written a sql server procedure which sends the result of a query as a csv file via e-mail. SQL server generates the attached file in UTF-8 BOM encoding. I need the attached file to be generated in UTF-8 (without BOM). I tried to…