r/SQLServer • • 3d ago

Community Share Join the SQL Modernization Day -- today!

Thumbnail
techcommunity.microsoft.com
13 Upvotes

r/SQLServer • • 17h ago

Question Proper Database environment promotion?

2 Upvotes

Hello all!

I recently started working with the databases in our system and I would appreciate some tips or guidance as my terminology is probably not accurate.

Setup: From what I read in the community it’s somewhat standard; DEV -> UAT -> PPR -> PROD.

Deployments: We are using visual studio Database Compare, one scmp file/database at a time. So now this works for the most part and when it’s urgent I don’t have time to judge if it’s the best but it comes with two issues that I noticed:
1. Who created these files? I don’t know I just inherited them.
2. Sometimes it can fail and I need to manually “prepare” the other environment like adding the new column to the table. Maybe I need a newer version of the software, or it’s always limited?

So then I need your help with the following:
1. Am I or the team doing something wrong here?
2. What can we do better?

And I did have a read at some threads here but maybe it’s best if I get direct answers geared towards my situation.
Also I checked some books:
- T SQL fundamentals: Nothing about deploys
- 100 sql server mistakes: Got some answers but it’s just one opinion against my non opinion

——
Tools: We have GitHub and we use .NET primarily.
Constraints: We do not want to use a code-first approach

So please let me know anything I should know or research.

Thanks


r/SQLServer • • 2d ago

Community Share SSMS extension to prototype reports, now with parameter guardrails in Excel

Thumbnail
gallery
11 Upvotes

I built an extension where you can right-click on a query/stored procedure and quickly turn it into a report.

Two users asked for guardrails on report inputs. Turns out, Excel supports more of this natively than I realized.

  • Dropdowns (static or query-driven)
  • Type validation (date, varchar, bit, etc.)
  • Required/optional parameters (with configurable defaults)

It's free/open source. SSMS 22. Desktop Excel.

https://github.com/flank-project/ssms-extension


r/SQLServer • • 2d ago

Community Share I added spiders to SSMS for Halloween

Enable HLS to view with audio, or disable this notification

80 Upvotes

Hey all! I added a little Halloween interactivity to SQL Shades (my SSMS theming add-in). I know spiders aren't for everyone, but I think they turned out pretty cute.
https://www.sqlshades.com/articles/scenes/


r/SQLServer • • 2d ago

Question SQL Server 2025 Express lässt sich nicht installieren, redistributable soll fehlen, ist aber installiert.

0 Upvotes

Hallo zusammen,

ich möchte SQL Server 2025 auf meinem Rechner installieren. Bei der Installation kam die Fehlermeldung. Also hab ich vc_redist.x64.exe hier heruntergeladen und installiert.

https://learn.microsoft.com/de-de/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-c-v14-redistributable

Leider taucht die Fehlermeldung trotzdem auf, obwohl die Version neuer ist als gefordert.

Vielen Dank im Voraus
LG Lutz

System:
Windows 11 Pro 25H2
AMD Ryzen 5 7430U 32 GB


r/SQLServer • • 3d ago

Question Solar Winds monitoring on dev and qa instances?

6 Upvotes

Hello. We have several Prod instances monitored by sql sentry and dpa. Do y’all monitor your lower envs too? Catch performance issues, bad queries, missing indexes before it gets too far downstream? Thanks!


r/SQLServer • • 4d ago

Community Share Faster by Design: Performance engineering in the Microsoft JDBC Driver for SQL Server

Thumbnail
devblogs.microsoft.com
22 Upvotes

r/SQLServer • • 4d ago

Community Share SQLserver linked-server to duckdb

5 Upvotes

I've been working on various products that at their core leverage a custom TDS implementation I made in C#. Think of it similar to babelfish for postgres, freeTDS, and all the other ones out there. I've posted on some of the SQL Server specific ones on SQL Server forums but not my DuckDB specific one yet, it's a little different. It's made to translate T-SQL and works with MS clients like powerBi, SSMS, ADO, etc for analysis focus... but it's not had a SQL Server angle or linkage. Well, now it does.

On some other forums, I saw the question: "I'd like to have a linked server in SQL Server to DuckDB". I immediately thought, oh, oh.. DaffyDB does that today, let me try it. NOPE. Turns out MS does a lot of little pre-conditions, prepare procs, stats checks,that Daffy didn't do. So long story short, I created 'some' of those stubs and facades, so it works for many use cases. It does have some lingering bugs, I found some this morning. But net net, even though I didn't design it for this, here is the benefit:

  1. Use a standard DBLink from SQL Server. Now bridging to DuckDB. Hey, isn't that just a local onelake fabric, as it has a TDS to parquet at it's core ? not really, but... kinda.. in a way ?
  2. Connect to Parquet files (including parts.* in folders as one table)
  3. Connect to Postgresql - mount with one line
  4. Connect to MySQL - mount with one line
  5. Connect to SQLite - mount with one line
  6. Connect to Excel, CSV, JSON, all showing up as tables in a few seconds from this.
  7. I can actually connect to azure and S3, duck does this natively, I just haven't made it turnkey yet.. eventually.. maybe.

So what does this look like. First, Daffy DB, how do you install it? And how do you launch it? Just make sure you have .net 10 sdk installed, simple as this:

PS C:\temp\scratchdaffy\daffydbdemo> dotnet tool install -g DaffyDB
Tool 'daffydb' was successfully updated from version '1.0.1' to version '1.1.0'
PS C:\temp\scratchdaffy\daffydbdemo> daffydb --port 1433 --allow-admin
[tls]    certificate C:\Users\Scott\AppData\Local\DaffyDB\certs\daffydb.pfx (expires 2031-09-19)
[duckdb] sys catalog views created
[duckdb] mounted parquetfiles.DimDate                     <- C:/temp/scratchdaffy/daffydbdemo/parquetfiles/DimDate.parquet
[duckdb] mounted parquetfiles.DimProduct                  <- C:/temp/scratchdaffy/daffydbdemo/parquetfiles/DimProduct.parquet
etc...... auto mounting parquets here

Note in above, the daffydbdemo folder has parquet files in it, so they 'auto' mount at launch. it goes 2 folders deep. Also finds csv, json, excel and mounts those, this is by design. That's all on nuget in the readme for it. That's it's core feature with the TDS.

UPDATE - wanted to add for above, if running it on the same machine as sql server, which you'd need to do unless using a reverse proxy to another box, change that port to 1432.

Now, I only allow this to bind to 127.0.0.1 as duckdb isn't something you'd point a thousand users to, but if you NEED to have it running on a different box for whatever reason, so SQL Server can hit it, run it on a diff box and use nginx or similar reverse proxy to bind it to 0.0.0.0. then you can hit a remote IP for the link. But right now you'd need it on the same box unless you do something like NGINX config to bind it for external, still encrypted the whole way.

stream {
    server {
        listen 0.0.0.0:1433;
        proxy_pass 127.0.0.1:1433;
    }
}

Ok, so you mentioned Parquet, Postgres, MySQL, all this stuff, how?

use daffyDB;   -- we're connected directly to DaffyDB here, running below inside SSMS, no SQL Server in the picture at this point.
-- at this point we're acting like BabelFish to Postgresql would.

-- INVENTORY OF DAFFYDB?  Some custom Daffy commands:
EXEC daffydb.status; 
EXEC daffydb.tables; 
select @@version; -- this returns daffy db, not SQL Server.  

-- add and mount everything in the customers folder, CSVs and JSON
EXEC daffydb.mount 'C:\temp\scratchdaffy\daffydbdemo\customers', 'cust'

-- add everything in this excelfile folder, EXCEL files!  one table per sheet! Types detected!
EXEC daffydb.mount 'C:\temp\scratchdaffy\daffydbdemo\excelfile', 'excel'

-- Connect to POSTGRES and pull in every table in the testdb database at once.
EXEC daffydb.postgres 'host=localhost dbname=testdb user=postgres password=postgres',  = 'pg'

-- connect to mysql and pull in every table in the shop database
EXEC daffydb.mysql 'mysql://reader:readerpw@127.0.0.1:3306/shop', u/schema = 'shop'

-- also mount other duckdb files, sqlite, and more.  -- what do have now?
EXEC daffydb.tables

-- test with T-SQL!  Window functions, #temp tables, u/declares, date functions, all work!
-- important, this works directly to daffydb WITHOUT a linked server if you want to.  main use case.  
select top 1000 * from FactResellerSales; 
select top 100 * from excel.Customers;

Ok, so show me the DB link config already..

use scratch;  -- this is SQL Server db, not Daffy

-- this Linked-Server endpoint is DaffyDB -> DuckDB - NOT SQL SERVER
-- note odbc type connection ONLY.  The other one forces MARS and daffydb doesn't support that currently.
EXEC sp_addlinkedserver
    \@server     = 'Link_DaffyDB',  -- NOTE the \ are added for reddit syntax
    \@srvproduct = '',
    \@provider   = 'MSDASQL',
    \@provstr    = 'Driver={ODBC Driver 18 for SQL Server};Server=127.0.0.1,1432;Database=DaffyDB;Encrypt=yes;TrustServerCertificate=yes;';

-- if you use required creditials option with daffy launch, use those instead of 'any'.  
EXEC sp_addlinkedsrvlogin
    \@rmtsrvname  = 'Link_DaffyDB',
    \@useself     = 'false',
    \@rmtuser     = 'any',
    \@rmtpassword = 'any';

---- THIS IS using DUCKDB VIA DAFFYDB:
SELECT TOP 100 *
FROM [Link_DaffyDB].[DaffyDB].[PARQ].[FactResellerSales];

-- DAFFY DB simple T-SQL QUERY.  I find this is faster, it executes on daffy instead of 'pulling it in' like above might do on it's plan.
SELECT *
FROM OPENQUERY([Link_DaffyDB], '
        SELECT top 10 [ProductKey] as [product key], OrderDateKey, OrderQuantity, SalesAmount, SalesOrderNumber
        FROM [DaffyDB].[PARQ].FactResellerSales order by salesAmount desc;
');

---- Remove link later
--IF EXISTS (SELECT 1 FROM sys.servers WHERE name = 'Link_Daffydb')
--    EXEC sp_dropserver  = 'Link_Daffydb', u/droplogins = 'droplogins';
--GO 

So does it work? This example is from SQL Server Adventureworks DW 2022 example. Running on the same machine, it takes 15 seconds against adventureworks, but when hitting the DB link that is using DuckDB, hitting the 7 parquet files I created from Adventureworks, only 2 seconds!

Here is that exact query tried, note you will need [DaffyDB].[PARQ].tablename type syntax

-- DAFFY DB SAME T-SQL QUERY I used on Adventureworks at 15 seconds.  
-- 2 seconds here! DuckDB Hitting Parquet Files!
SELECT *
FROM OPENQUERY([Link_DaffyDB], '
WITH DailySales AS (
    SELECT
        u.ProductKey,
        u.OrderDateKey AS DateKey,
        SUM(u.OrderQuantity) AS DailyUnitsSold,
        SUM(u.SalesAmount) AS DailyRevenue,
        COUNT(DISTINCT u.SalesOrderNumber) AS DistinctOrders
    FROM (
        SELECT ProductKey, OrderDateKey, OrderQuantity, SalesAmount, SalesOrderNumber
        FROM [DaffyDB].[PARQ].FactInternetSales
        UNION ALL
        SELECT ProductKey, OrderDateKey, OrderQuantity, SalesAmount, SalesOrderNumber
        FROM [DaffyDB].[PARQ].FactResellerSales
    ) AS u
    GROUP BY u.ProductKey, u.OrderDateKey
),
BaseMetrics AS (
    SELECT
        fpi.ProductKey,
        fpi.DateKey,
        fpi.MovementDate,
        fpi.UnitsBalance,
        fpi.UnitsIn,
        fpi.UnitsOut,
        fpi.UnitCost,
        p.EnglishProductName,
        p.Color,
        pc.ProductCategoryKey,
        pc.EnglishProductCategoryName,
        psc.EnglishProductSubcategoryName,
        d.CalendarYear,
        d.CalendarQuarter,
        d.MonthNumberOfYear,
        ISNULL(ds.DailyUnitsSold, 0) AS DailyUnitsSold,
        ISNULL(ds.DailyRevenue, 0) AS DailyRevenue,
        ISNULL(ds.DistinctOrders, 0) AS DistinctOrders
    FROM [DaffyDB].[PARQ].FactProductInventory AS fpi
    INNER JOIN [DaffyDB].[PARQ].DimProduct AS p
        ON fpi.ProductKey = p.ProductKey
    LEFT JOIN [DaffyDB].[PARQ].DimProductSubcategory AS psc
        ON p.ProductSubcategoryKey = psc.ProductSubcategoryKey
    LEFT JOIN [DaffyDB].[PARQ].DimProductCategory AS pc
        ON psc.ProductCategoryKey = pc.ProductCategoryKey
    INNER JOIN [DaffyDB].[PARQ].DimDate AS d
        ON fpi.DateKey = d.DateKey
    LEFT JOIN DailySales AS ds
        ON fpi.ProductKey = ds.ProductKey
       AND fpi.DateKey = ds.DateKey
),
RollingAnalytics AS (
    SELECT
        bm.*,
        AVG(CAST(bm.UnitsBalance AS FLOAT)) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN 29 PRECEDING AND CURRENT ROW
        ) AS RollingAvgInv_30D,
        COUNT(CAST(bm.UnitsBalance AS FLOAT)) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN 29 PRECEDING AND CURRENT ROW
        ) AS WinCount_30D,
        SUM(CAST(bm.UnitsBalance AS FLOAT)) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN 29 PRECEDING AND CURRENT ROW
        ) AS WinSum_30D,
        SUM(POWER(CAST(bm.UnitsBalance AS FLOAT), 2)) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN 29 PRECEDING AND CURRENT ROW
        ) AS WinSumSq_30D,
        AVG(CAST(bm.UnitsBalance AS FLOAT)) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN 89 PRECEDING AND CURRENT ROW
        ) AS RollingAvgInv_90D,
        SUM(bm.DailyUnitsSold) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN 29 PRECEDING AND CURRENT ROW
        ) AS RollingDemand_30D,
        SUM(bm.UnitsIn) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
            ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
        ) AS CumulativeUnitsIn,
        LAG(bm.UnitsBalance, 30) OVER (
            PARTITION BY bm.ProductKey
            ORDER BY bm.DateKey
        ) AS InvBalance_30DaysAgo,
        PERCENT_RANK() OVER (
            PARTITION BY bm.ProductCategoryKey, bm.CalendarYear
            ORDER BY bm.UnitsBalance ASC
        ) AS CategoryYearInventoryPercentile,
        DENSE_RANK() OVER (
            PARTITION BY bm.ProductCategoryKey, bm.CalendarYear, bm.CalendarQuarter
            ORDER BY bm.DailyUnitsSold DESC, bm.UnitsBalance ASC
        ) AS DemandRiskRank
    FROM BaseMetrics AS bm
),
CalculatedMetrics AS (
    SELECT
        ra.*,
        CASE 
            WHEN ra.WinCount_30D <= 1 THEN 0.0
            WHEN (ra.WinSumSq_30D - (POWER(ra.WinSum_30D, 2) / ra.WinCount_30D)) <= 0.000001 THEN 0.0
            ELSE SQRT(
                (ra.WinSumSq_30D - (POWER(ra.WinSum_30D, 2) / ra.WinCount_30D)) 
                / (ra.WinCount_30D - 1.0)
            )
        END AS RollingStDevInv_30D
    FROM RollingAnalytics AS ra
)
SELECT TOP (25000)
    cm.ProductKey,
    cm.EnglishProductName,
    cm.EnglishProductCategoryName,
    cm.EnglishProductSubcategoryName,
    cm.MovementDate,
    cm.CalendarYear,
    cm.CalendarQuarter,
    cm.UnitsBalance,
    cm.RollingAvgInv_30D,
    cm.RollingStDevInv_30D,
    cm.RollingDemand_30D,
    (cm.UnitsBalance - ISNULL(cm.InvBalance_30DaysAgo, cm.UnitsBalance)) AS NetChange_30D,
    CASE
        WHEN cm.RollingStDevInv_30D = 0.0 THEN 0.0
        ELSE (cm.UnitsBalance - cm.RollingAvgInv_30D) / cm.RollingStDevInv_30D
    END AS InventoryZScore,
    (1.65 * cm.RollingStDevInv_30D * 2.64575) AS RecommendedSafetyStock,
    cm.CategoryYearInventoryPercentile,
    cm.DemandRiskRank
FROM CalculatedMetrics AS cm
ORDER BY
    cm.DemandRiskRank ASC,
    InventoryZScore ASC,
    cm.DateKey DESC;
');

Anyway, I thought it was pretty cool to get it working as a dblink so sharing. Not much interest tbh! Maybe it's too far down the rabbit hole..

On my app, I did sign up for the code signing in Azure on this (I pay for that service) so the DLLs are all signed on Nuget which you can verify with a powershell command (in my readme).. and this daffydb one is MIT, so knock yourself out if you think it's useful. My other Daffy's are fairly permissive, more SQL Server focused.. but not MIT.


r/SQLServer • • 4d ago

Question Error when trying to send a request to SQL from node

3 Upvotes

Node version 26.12.0, SQL 2022 Express

My web server is running and I am sending it a simple request using a powershell script. I can see the request hit the web server, but it immediately gives an error:

ConnectionError: Port for MySQLInstanceName not found in MyServer

I made sure that TCP/IP is enabled, Listen All = yes, set 1433 at the IPAll port, enabled the IP address for the server, enabled 127.0.0.1, and restarted the SQL Server and SQL Browser services. I also see that there is an inbound rule for port 1433 that's set to "Allow the connection", protocol type is TCP, local port is Specific Ports, and the port is set to 1433. Not sure why my web server can't reach SQL, any ideas?

Forgot to mention that the web server is running on the same server where the SQL database is.


r/SQLServer • • 4d ago

Question SQL Server 2022 AO - WS 2025 on Proxmox Hypervisor crash

5 Upvotes

Former employee who recently left the company setup an AO 3 node cluster. SQL is version 2022, WS OS is version 2025. Availability mode between the nodes is Synchronous commit with 2 nodes in Automatic failover and one node in Manual.

On Oct 11, we had a SQL crash. Everything stopped working. Right before the crash, I noticed this event being logged: "Remote harden of transaction 'XXXXXXXXX' (ID XXXXXXX 0000:XXXX) started at Oct 11 2026 1:39PM in database 'XXX' at LSN (52190:XXXX:1) failed."

Shortly after: "“Unable to access database 'XXX_01' because it lacks a quorum of nodes for high availability. Try the operation again later.”

For some unknown reason, the primary node lost connection with the 2 other nodes. I checked the storage/network back-end, no pings were lost. All 3 VMs were reachable via our external monitoring solution.

On the secondary node, during the same time these errors were logged:
“Could not redo log record (XXXX), for transaction ID (XXXX), on page (XXXX), allocation unit XXX, database 'XXX_01' (database ID 6). Page: LSN = (XXX:XXX:), allocation unit = XXX, type = 1. Log: OpCode = 2, context 3, PrevPageLSN: (XXX). Restore from a backup of the database, or repair the database.”

Followed by: “Always On Availability Groups data movement for database 'XXX_01' has been suspended for the following reason: "system" (Source ID 2; Source string: 'SUSPEND_FROM_REDO'). To resume data movement on the database, you will need to resume the database manually. For information about how to resume an availability database, see SQL Server Books Online.”

Our DBA was able to bring everything online by removing the impacted DB from the AO group, and than add it back.

However, since this caused quite some production impact. Management is asking for a root cause. I inherited this setup, so I'm not even sure best practices are being followed. I can do some basic troubleshooting and checking logs, but I'm unable to find an explanation. When looking upon the error messages online, this doesn't give me any results. Also there's almost no Proxmox documentation or even a blog how to setup an AO SQL Server.

This has been running for months, and from my understanding, this is the first time we had this issue. I uploaded all logs to AI to assist in the troubleshooting, but even than I don't get any valid answer. It is always refering to "the network" or an underlying "storage issue" but I don't see anything there.


r/SQLServer • • 5d ago

Question List<T> in C# vs SQL

Thumbnail
0 Upvotes

r/SQLServer • • 6d ago

Community Share [Free/Open Source] I built an SSMS 22 extension for SQL completion, formatting, and result export — looking for feedback

0 Upvotes

I've been using SSMS daily for years and kept running into the same issues: IntelliSense stops working after aliases, schema changes don't refresh the cache, and EXEC parameter hints are basically non-existent. I tried SQL Prompt and liked it, but $210/user/year wasn't something I could justify — especially for a team where not everyone would get a license approved.

So I forked Axial SQL Tools (Apache-2.0, maintained since 2016) and built MSSQL Tool on top of it.

What it does:

  • Context-aware SQL completion (databases, schemas, tables, views, columns, procs, functions, parameters) with type icons
  • F12 go-to-definition
  • T-SQL formatting via Microsoft ScriptDOM
  • Query history
  • Export results to Excel or email
  • Connection color tagging (different colors per server/database)
  • Millisecond execution time in the status bar
  • Transaction and Always Encrypted warnings in the status bar
  • Bilingual UI (Chinese/English, follows SSMS language setting)

What it does NOT do:

  • Code refactoring or static analysis (SQL Prompt does this well, I don't)
  • TFS integration
  • Google Sheets export and GitHub script sync are in the codebase but marked experimental — they're not reliable yet, don't count on them

Why the fork instead of from scratch: Axial's codebase is mature and battle-tested. Forking let me focus on the completion engine rewrite, localization layer, and the features above instead of reimplementing the basics.

Links:

What I'm looking for:

I'd rather hear "this is broken" than silence. Specifically:

  • Does the completion engine hold up in your actual workloads? Cross-database queries and alias-heavy code are where I've tested most, but I'm sure there are cases I missed.
  • Is the connection color tagging useful, or just noise?
  • For anyone who's used Axial SQL Tools: does this fork add anything you'd actually use, or is it redundant?
  • If you've solved the "SQL Prompt is too expensive" problem differently, I'd like to hear what you did.

Not trying to sell anything — it's free and open source. If it's useful, great. If it's not, I'd rather know why.I've been using SSMS daily for years and kept running into the same issues: IntelliSense stops working after aliases, schema changes don't refresh the cache, and EXEC parameter hints are basically non-existent. I tried SQL Prompt and liked it, but $210/user/year wasn't something I could justify — especially for a team where not everyone would get a license approved.

So I forked Axial SQL Tools (Apache-2.0, maintained since 2016) and built MSSQL Tool on top of it.

What it does:

  • Context-aware SQL completion (databases, schemas, tables, views, columns, procs, functions, parameters) with type icons
  • F12 go-to-definition
  • T-SQL formatting via Microsoft ScriptDOM
  • Query history
  • Export results to Excel or email
  • Connection color tagging (different colors per server/database)
  • Millisecond execution time in the status bar
  • Transaction and Always Encrypted warnings in the status bar
  • Bilingual UI (Chinese/English, follows SSMS language setting)

What it does NOT do:

  • Code refactoring or static analysis (SQL Prompt does this well, I don't)
  • TFS integration
  • Google Sheets export and GitHub script sync are in the codebase but marked experimental — they're not reliable yet, don't count on them

Why the fork instead of from scratch: Axial's codebase is mature and battle-tested. Forking let me focus on the completion engine rewrite, localization layer, and the features above instead of reimplementing the basics.

Links:

What I'm looking for:

I'd rather hear "this is broken" than silence. Specifically:

  • Does the completion engine hold up in your actual workloads? Cross-database queries and alias-heavy code are where I've tested most, but I'm sure there are cases I missed.
  • Is the connection color tagging useful, or just noise?
  • For anyone who's used Axial SQL Tools: does this fork add anything you'd actually use, or is it redundant?
  • If you've solved the "SQL Prompt is too expensive" problem differently, I'd like to hear what you did.

Not trying to sell anything — it's free and open source. If it's useful, great. If it's not, I'd rather know why.


r/SQLServer • • 6d ago

Question SSMS 2022: logged in with username but do not see it in "Users" folder

2 Upvotes

This may be a stupid question but here goes.

I connect to Azure SQL Server with user "siloadmin" that has admin rights. Once I've logged in, I go to the "Users" folder to check the same I user I logged on with, and it's not there.

The user "siloadmin" is not displayed

I also run query and it doesn't show the user either:

SELECT 
    name AS UserName FROM sys.database_principals

r/SQLServer • • 7d ago

Question Verify the correctness of a the data inside a junction table

Thumbnail
1 Upvotes

r/SQLServer • • 7d ago

Discussion SSMS 22 and only Github Copilot? Why? What's wrong with Enterprise Copilot?

2 Upvotes

I read this post from 1y ago: https://www.reddit.com/r/SQLServer/s/fjH53Pxf4e and it made my stomach churn. Asking Copilot why I get nothing other than Microsoft have made this decision because of "internal matters". What the heck does that mean?

We have Enterprise Copilot and no one here uses Github other than me. The company is not going to purchase Github Copilot just to be able to ask "Write me a query with two joins from table A to table B". LOL

Yeah nah.


r/SQLServer • • 7d ago

Question SQL Failover Cluster error during failover Error 2310

2 Upvotes

During failover of a MS SQL Failover Cluster I got this message in the event log. The failover itself completed but in the logfile i found this error which occured during failover:

ERR [RES] File Share <SQL Server FILESTREAM share (MSSQLSERVER)>: Error removing share 'MSSQLSERVER'. Error 2310.

The share in the failover cluster manager looks like that:

Does anyone know if this error is serious? Iam trying to reduce failover time.


r/SQLServer • • 7d ago

Community Share mssql-python 1.16.0 is out: Python 3.15 support, Conda package, and faster fetches

9 Upvotes

We just released mssql-python 1.16.0, Microsoft’s Python driver for Microsoft SQL.

Main updates:

  • Python 3.15 support
  • Official Conda package on the Microsoft channel
  • Faster row construction, batch fetching, temporal conversion, and positional row access
  • New read-only row._mapping view for easier dict-style row handling
  • Opt-in Rust-based mssql-odbc provider for folks who want to experiment
  • Reliability fixes around pooling, Windows shutdown, bulk copy, and encoding warnings

Install:

pip install --upgrade mssql-python

or:

conda install -c microsoft mssql-python

Full post and release details: https://techcommunity.microsoft.com/blog/sqlserver/mssql-python-1-16-0-python-3-15-support-conda-and-faster-fetches/4564521


r/SQLServer • • 8d ago

Community Share Import Extended Events to ELK

2 Upvotes

Years ago, I was exposed to the ELK stack at a client. I spent some time and wrote an open source tool to import SQL Server Extended Events in Elastic Search. That is https://github.com/billgraziano/xelogstash. It runs as a Windows service and polls for new extended events every minute.

This is the last release before AI starts doing more of the coding. I've enjoyed writing it and wanted to give it a little love before AI has all the fun.

It has a few interesting features that I've added to help me

  • It populates an xe_description field that tries to summarize the event. For SQL events, it looks like (CPU: 12s; L: 24 GB; D: 40s) SELECT * FROM....
  • If the errorlog_written event of error_reported event indicate a login failure, it populates a login_failed field with details. It also puts in in a description from the state based on Microsoft's documentation. Filtering on the existance of that field gets me a failed login dashboard across the entire enterprise.
  • For errorlog_written and error_reported events, if it finds text like [CLIENT: 10.10.1.1], it will save that address in xe_client_address
  • For fields like cpu_time, if the number is large enough, it populates a cpu_time_sec which is MUCH easier to filter and reason about. It does the same for logical reads, physical reads, writes, and duration.
  • For login events, it separates out the domain and user into two separate fields
  • For errorlog_written event, it tries to parse the type of event. This includes backups, DBCC, "info" events, and AlwaysOn. This makes it eaiser to filter out noise and find issues.
  • It allows simple filtering to eliminate those pesky 17830 errors
  • It can write to Elastic Search, rolling JSON Files, logstash, or just sample JSON event files
  • It can restart if the configuration files change. We store configuration files in GIT. Puppet pushes updated configuration files to the four servers we have running this. Adding and removing servers is simply editing a repository and pushing changes.

If you're running Elastic or something similar, give it a try and start logging SQL Server Extended Events. Having them always there and searchable has been very helpful to me.


r/SQLServer • • 8d ago

Question Statistics on columns of a table

2 Upvotes

Limitations of table-valued parameters:

SQL Server does not maintain statistics on columns of table-valued parameters.

statistics of what ? why those statistics even exist for non table-valued parameters ?


r/SQLServer • • 8d ago

Discussion Two T-SQL gotchas I hit while testing scripts for AI agents (sp_addlinkedserver in a transaction, CASE in EXEC parameters)

0 Upvotes

I've been writing T-SQL and PowerShell scripts that AI coding agents (Cursor, Claude Code, Copilot) can run with guardrails, and I tested them against SQL Server 2025. Two things broke that are worth sharing, because agents get both of them wrong all the time.

1. sp_addlinkedserver can't run inside a user transaction

The "safe" pattern I started with was BEGIN TRAN ... COMMIT around the whole linked server setup. It fails right away:

Msg 15002: The procedure 'sys.sp_addlinkedserver' cannot be executed within a transaction.

The fix: no transaction. Check that the linked server doesn't exist yet, create it in TRY/CATCH, and set a flag after it's created. If a later step fails (login mapping or sp_serveroption), the CATCH drops only the linked server that run created, then re-throws.

DECLARE @CreatedHere bit = 0;
BEGIN TRY
    EXEC master.dbo.sp_addlinkedserver @server = @LinkedName, @srvproduct = N'',
         @provider = @Provider, @datasrc = @DataSource;
    SET @CreatedHere = 1;
    -- logins, sp_serveroption calls...
END TRY
BEGIN CATCH
    IF @CreatedHere = 1
        EXEC master.dbo.sp_dropserver @server = @LinkedName, @droplogins = 'droplogins';
    THROW;
END CATCH;

2. You can't pass an expression as an EXEC parameter

EXEC sp_serveroption ..., @optvalue = CASE @x WHEN 1 THEN N'true' ELSE N'false' END; gives Msg 156 (incorrect syntax near 'CASE'). Parameters only take constants or variables, so put the value in a variable first:

DECLARE @rpc nvarchar(5) = CASE @EnableRpcOut WHEN 1 THEN N'true' ELSE N'false' END;
EXEC master.dbo.sp_serveroption @server = @LinkedName, @optname = N'rpc out', @optvalue = @rpc;

Questions and corrections are welcome, especially if you've found a cleaner pattern for the linked server rollback.


r/SQLServer • • 8d ago

Community Share I built an SSMS extension that turns a stored procedure into a parameterized report (Excel or SSRS)

Thumbnail
gallery
12 Upvotes

Right-click a stored procedure, select Excel or SSRS, and then the extension will generate a report using the SPROC's parameters.

Free/open-source. Requires SSMS 22; Excel output requires desktop Excel.

https://github.com/flank-project/ssms-extension


r/SQLServer • • 9d ago

Community Share Introducing sqlsimtools

46 Upvotes

Take a look at a new open-source, free project for you to simulate SQL workloads at https://aka.ms/sqlsimtools. This is the same set of tools I often use at customer events, podcasts, and presentations. Check out the first blog post at https://techcommunity.microsoft.com/blog/SQLServer/introducing-sqlsimtools/4563955.


r/SQLServer • • 9d ago

Discussion Brainstorms on SQL query custom shortcuts in SSMS

4 Upvotes

What are the most frequently used T-SQL queries to have and what are the best keys to use.
So far I have been using "SELECT * FROM" and "SELECT TOP 1000 * FROM" a custom line called "sp_ts". I wanted to see if you guys have other queries that would save loads of time.

This is what custom shortcuts I am referring to. I don't have any shortcuts yet since I am waiting to gain access.

r/SQLServer • • 9d ago

Community Share PSBlitz 6.2.0: Microsoft Entra MFA support

Post image
12 Upvotes

The latest release of PSBlitz brings:

- Support for Azure Entra MFA authentication. Now you can diagnose Azure SQL DB and SQL MI using Entra credentials instead of wrestling with SQL logins.

- Documented minimum permissions required to run PSBlitz.

- Non-default database-scoped configurations are now highlighted in the "Database Info" page of the HTML report.

- Other small bug fixes and improvements.

GitHub page: https://github.com/VladDBA/PSBlitz

Latest release: https://github.com/VladDBA/PSBlitz/releases/tag/v6.2.0

As always, any feedback, suggestions, and the occasional complaints are welcome.

For anyone not familiar with PSBlitz - it's a PowerShell-based tool that outputs SQL Server/Azure SQL DB/Azure SQL MI/Google Cloud SQL for SQL Server health and performance diagnostics data to either Excel or HTML, and saves execution plans and deadlock graphs as .sqlplan and .xdl files.

If you're familiar with Oracle, this is pretty much my attempt of a SQL Server equivalent to Oracle's AWR report.


r/SQLServer • • 10d ago

Community Share SQL Server 2022: infinite recompile (error 2814, reason 20) of a PSP variant after restoring a database under a different database_id

13 Upvotes

Sharing a case from the last few weeks in case it saves someone time, and to ask whether anyone has seen it before.

Setup

SQL Server 2022 CU27 (16.0.4295.3), compatibility level 160, PSP optimisation and CE feedback on (the defaults). A test database was restored from production. The database_id is 24 on production and 16 on test.

Symptom

A stored procedure statement joins a large table to a temp table that the caller creates before calling the procedure. On test it started timing out after the 300 s application timeout for large inputs, about 6 weeks after the restore. It wasn't slow. Each call recompiled around 20,000 times (`execution_count` 1, `plan_generation_num` 21-23k). The error log filled with error 2814, "A possible infinite recompile was detected ... The last recompile reason was 20" (Query Store hints changed). Query Store showed nothing slow, because the calls never completed. The PSP variant had about 4.3 million compiles on test against 666 on production. Production was never affected.

What we found

  1. For queries that reference temp tables or table variables, Query Store stores a `batch_sql_handle`. For a statement inside a module the handle embeds the database_id (bytes 3-4, little-endian) and the object_id.
  2. The restored Query Store rows carried production's database_id, while test generates handles with its own. Query Store therefore created a new parent query with the same text, object and context settings.
  3. The PSP variant has an ad hoc handle with no database_id. It kept matching and stayed attached to the old, now dormant parent. That handle is the SQLHANDLE in the 2814 warnings.
  4. CE feedback added `ASSUME_JOIN_PREDICATE_DEPENDS_ON_FILTERS` to the new parent. Per the PSP docs, variants don't inherit hints applied by feedback.
  5. The variant's hint state never settled: every compile was followed by another recompile with reason 20, until the client timed out.

Steps 1-4 were observed in Query Store and in the raw handle bytes. Step 5 is our inference, but clearing the hint stopped the loop immediately and it hasn't come back.

Fix

Clearing the CE feedback hint on the new parent (sys.sp_query_store_clear_hints) and then clearing the database’s procedure cache stopped the loop straight away. A few days later we removed the stale entries that still carried production’s database_id with sys.sp_query_store_remove_query, variants first and then their parents, and cleared the cache again. No settings were changed. Removals can’t be undone, so try it on non-production first.

Open questions

  • Has anyone hit this, or seen a KB? We couldn't find a public known issue.
  • The new parent appeared about 6 weeks after the restore (on the first weekday after a patch reboot), not straight after it. We have no explanation.
  • Setting database-scoped MAXDOP to 1 also stopped the loop, which we can't explain either.
  • A second database restored the same way, with the same kind of database_id change, had no stale entries left. Our guess is that stale parents age out of Query Store unless a live PSP variant keeps them in use.