Recent Discussions
Database Level Collation Issues
Some background information. In the past we had a database where we didn't really care about collation at the database, table/column, functions and views. Though now we have a requirement due to a technology acquisition, requires SQL_Latin1_General_CP1_CI_AS. Microsoft seems to not have a simple method that guarantees changing the collation throughout the database on complex DBs with large amounts of tables, columns, functions, etc... specially with high dependencies, FKs and PKs and not affect any of the data (no moving the data is not simple). I have a command, where I stop all of the SQL services and any connections to the DB and use the following command line to change the collation to the one I specify. The issue is this command only works about 65% of the time and no clue to the why it fails the other 35%. The command used is: The parameter "-s" is necessary only if you have a named instance, remove the -s if no instance. sqlservr -m -T4022 -T3659 -s"SQL2019" -q"SQL_Latin1_General_CP1_CI_AS" or sqlservr -m -T4022 -T3659 -q"SQL_Latin1_General_CP1_CI_AS" When this does not work, I have a set of 6 SQL scripts to tear the database apart in a complex method to get them operational. Does anybody have any idea why the hit and miss on the command? Or a better method / way to fully change the DB collation?5Views0likes0CommentsStruggling with AI/ML and Python installation on MSSQL2025 GA
I swear that i did not have any issues installing AI/ML on CTP2.1, don't believe i tried it on RC0 or RC1, but gosh is installing python, R difficult on GA! wow ! Can Microsoft or some good soul please share exact steps on installing AI/ML on 2025GA w/ Python 3.10 and also please share all of the exact versions needed and the icals (permission setups), Also I'm confused with this virtual account vs domain account setups. Also can i use Python 3.13 or 3.14 ? or am i locked into 3.10 only ? Does any one have the exact steps on Windows 11 Pro for a SQL Server 2025 Enterprise Development environment ? I see this article but its so confusing : https://learn.microsoft.com/en-us/sql/machine-learning/install/sql-machine-learning-services-windows-install-sql-2022?view=sql-server-ver17&viewFallbackFrom=sql-server-ver1545Views0likes2CommentsMajor increase in transaction log backup size after upgrading to SQL Server 2022
Has anyone experienced a major increase in transaction log backup size after upgrading to SQL Server 2022? I recently upgraded one of our SQL Server environments from SQL Server 2019 to SQL Server 2022 (migrated databases to new SQL Server 2022 instances). After the upgrade, I noticed that transaction log backup sizes increased by 3× to 5×, even though: No application changes were made Workload and data change volume should be roughly the same Backup schedule remained the same (log backups every 30 minutes) Backup compression is default (same as before) The database is part of an Always On Availability Group running in synchronous commit mode Metrics I obeserved: Transaction log backup file size — increased 3× to 7× Log Write Throughput/sec — more than doubled Write Log Throughput — increased after upgrade Background Write Pages/sec — went up as well Log Bytes Flushed/sec Bytes Sent to Replica/sec — increased post-upgrade Backup/Restore Throughput/sec — increased from ~13 MB/sec → ~38 MB/sec Bytes Sent to Replica/sec (Always On counter) — increased New hardware is used — previous physical disk sector size was 4K, now it's 512 bytes Same Amount of RAM and CPU51Views0likes3CommentsSQL Ssrver Query Optimisation
Hi everyone, I am currently building a SQL report, but i need somebody to help me optimize my query. The query is working fine and pulling data, only if a selected a specific product (one or two), But when i need to pull data without that filter, the query is taking more time to show results, and i am not getting any data pulled. Here is my SQL Query : WITH WeighingData AS ( SELECT CASE TRANS_TYPE WHEN 2 THEN 'Dispatch' WHEN 1 THEN 'Receiving' WHEN 0 THEN 'Cancelled' END AS Transaction_Type, w.TIMESTAMP_1, w.TIMESTAMP_2, w.TICKETNO, w.HAULIER, w.IMAGE_1_1, w.IMAGE_1_2, w.IMAGE_2_1, w.IMAGE_2_2, w.OPERATOR_1 AS 'Operator ID1', w.OPERATOR_2 AS 'Operator ID2', xind1.FULL_NM AS 'Operator1_Fullname', xind2.FULL_NM AS 'Operator2_Fullname', w.PRODUCT, w.NET, w.VEHICLE_MANIFEST, w.DESPATCH_ORDER, w.WEIGHT_1, w.WEIGHT_2, w.BOL, ISNULL(d.DRIVER_NAME, N'') + ISNULL(d.DRIVER_SURNAME, N'') AS Driver_Fullname, v.LICENSEPLATE, st1.TERMINAL AS WBG1, st2.TERMINAL AS WBG2, p.NAME, ROW_NUMBER() OVER (PARTITION BY w.TICKETNO, w.VEHICLE_MANIFEST, w.DESPATCH_ORDER ORDER BY st1.TRANSIT_TIME DESC) AS RowNum FROM [Multiweigh].[Flexpoint].[WEIGHING] w INNER JOIN Flexpoint.PRODUCT p ON p.CODE = w.PRODUCT INNER JOIN Flexpoint.DRIVER d ON d.DRIVER_ID = w.DRIVER_ID LEFT OUTER JOIN Flexpoint.VEHICLE v ON v.LICENSEPLATE = w.VEHICLE LEFT JOIN Flexpoint.STAGING_TRANSIT st1 ON st1.PARAMETER_3 = w.VEHICLE_MANIFEST OR st1.PARAMETER_4 = w.DESPATCH_ORDER LEFT JOIN Flexpoint.STAGING_TRANSIT st2 ON st2.PARAMETER_3 = w.VEHICLE_MANIFEST OR st2.PARAMETER_4 = w.DESPATCH_ORDER LEFT JOIN Flexpoint.XINDIVIDUAL xind1 ON xind1.USERINDIV = w.OPERATOR_1 LEFT JOIN Flexpoint.XINDIVIDUAL xind2 ON xind2.USERINDIV = w.OPERATOR_2 INNER JOIN Flexpoint.XSTATION x ON x.STATION = w.STATION WHERE w.TIMESTAMP_1 BETWEEN '2024-08-04 00:00:00' AND '2024-08-04 23:59:59' AND w.PRODUCT IN (@Product_Name) AND w.TICKETNO LIKE @Ticket_No AND TRANS_TYPE IN (@Transaction_Type) ) SELECT *, CONCAT(CAST([Operator ID1] AS NVARCHAR(50)), ' - ', [Operator1_Fullname]) AS Operator1_Info, CONCAT(CAST([Operator ID2] AS NVARCHAR(50)), ' - ', [Operator2_Fullname]) AS Operator2_Info FROM WeighingData WHERE RowNum = 1 AND ([WBG1] LIKE '%weighb%' OR [WBG2] LIKE '%weighb%');Solved345Views0likes2CommentsDetermine a Value from a customized field in a select statement.
I am new. I am looking to determine the value of a customized field based on the value of a previous customized field. Here is what I have so far: select c.*, CASE WHEN c.[Case End Date] is null Then DATEDIFF(day,c.[Case Start Date], getdate()-1) ELSE DATEDIFF(day,c.[Case Start Date], c.[Case End Date]) END as [Days Open], CASE WHEN [DAYS OPEN] > 60 THEN 1 ELSE 0 END AS [60DAYSORMORE] From d_case as c The issue I have is that the system will not recognize my [Days Open] as a field. Msg 207, Level 16, State 1, Line 9 Invalid column name 'DAYS OPEN'. How can I make this work in Microsoft SQL Server Management Studio?55Views0likes2CommentsError Locating Server/Instance Specified - Tried everything I can find
Hello SQL experts, I am sort of at my wits end at this point and was hoping someone from the community could help me, I have referenced several discussions on this community and still have not found a solution that worked for my situation. I am trying to set up a automatic backup solution for a SQL Express Server so I can't use the SQL Agent to schedule a backup. Below is a batch script for sqlcmd I am trying to use to create the backup and as soon as I have it working, I plan on scheduling it as a task that will be executed weekly. I have also included the SQL query that works just fine when run from inside SSMS and creates the backup as expected. Batch file script: Echo off REM ================================================================ REM BackupDatabase.bat REM ================================================================ REM --- Configuration --- SET SERVER_NAME=.\FTVIEWX64_SRSS SET USER_NAME=xxxxxx SET PASSWORD=xxxxxx SET SQL_SCRIPT=C:\Users\Public\Documents\xxxx_BackupDatabase.sql REM --- display timestamp --- echo [%date% %time%] Starting database backup... REM --- Run SQLCMD --- sqlcmd -S %SERVER_NAME% -U %USER_NAME% -P %PASSWORD% -i "%SQL_SCRIPT%" IF %ERRORLEVEL% EQU 0 ( echo [%date% %time%] Backup completed successfully. ) ELSE ( echo [%date% %time%] Backup FAILED! Error code: %ERRORLEVEL% ) pause SQL Query being used: -- BackupDatabase.sql DECLARE @BackupFileName NVARCHAR(255); SET @BackupFileName = N'D:\SQLdbBackup\XXXX_' + CONVERT(VARCHAR(8), GETDATE(), 112) + N'.bak'; BACKUP DATABASE XXXX TO DISK = @BackupFileName WITH NOFORMAT, NOINIT, NAME = N'Full Backup of XXXX', SKIP, NOREWIND, NOUNLOAD, STATS = 10; GO When I run the batch file I get this in the sqlcmd window as an error code: The necessary services all seem to be running fine as you can see below: The sqlcmd version is as follows: SQL server version is as follows: Connections for the server are configured as follows: Any and all help would be greatly appreciated so I can resolve the issue and get regular backups scheduled for this server. Thanks and Kind Regards, DanSolved142Views0likes2CommentsExporting a database: "Choose a data source." What???
I'm trying to export a SQL Server database, and things aren't going well. I hope someone can help. First, the problem I've solved. I mention it because it may be a clue to what went wrong next. I started SSMS (version 21.5.14+6.36429.23, if that matters), right clicked the database I want to export, and selected Tasks > Export Data. Whoops... Export Data was disabled. I researched this and learned that I must need to install the Import/Export Wizard. Which made no sense, because Import was enabled, and I have imported a database before. (If I hadn't, I'd have none to export!) I tried to (re)install the Wizard, and that fixed the problem, although I still don't understand how it could have. So, I clicked Export Data and got a Welcome screen. I clicked Next and got a screen titled Choose a Data Source. This is incomprehensible to me. I'm running the SQL Server Import/Export Wizard. I got there by right-clicking a particular database in a particular server. The only possible data source is that database. But the Wizard wasn't happy with that, and offered me a dropdown list of 13 options that meant nothing to me. I figured I couldn't go wrong with the default, but I did. The default was "Net Framework Data Provider for Odbc." When I clicked Next, I got an error box that said, "The operation could not be completed. / The ConnectionString property has not been initialized. (System.Data)" I could look up the meaning of the message, but I'm not sure that's what I want to know. Or I could look up the meanings of all 13 options in the dropdown and try to figure out which one to use to export a database, but I've got other things I need to do today. I came here.86Views0likes1CommentI need to find a string in a database without knowing table or field
I have a database that contains approximately 130 tables. It's tied to a proprietary application, and I have no way to find its structure except by reverse engineering. But I only need to find the table that contains one particular field in the application's UI, so I thought I'd take a shortcut: use Windows Explorer to search the Microsoft SQL Server directory (and children) for a file that contains a string that I know is in the database. I did this, and got zero matches. I checked how SQL Server stores CHAR and VARCHAR fields. I found that it stores them in UTF-8 encoding. OK, I thought, perhaps Windows Explorer can't find strings encoded in UTF-8. Or perhaps it's programmed to ignore files in the SQL Server folder, like it ignores files in Git repositories. So I tried searching for the string with Notepad++'s Find in Files function. And again, found nothing. What is going on here? Is there any way I can search the raw database files without using SQL Server itself? Alternatively, is there some way I can search an entire database for a string without knowing what column or table it is in?104Views0likes1CommentFailure to run query
Hi, ALL, First I believe that this question is more suited for a C++ devs,, but I can't find it. Sorry. I'm trying to run following query: query1= L"SELECT name FROM sys.key_constraints WHERE type = 'PK' AND parent_object_id = OBJECT_ID(?.?.?);"; with the code below: cbLen[0] = cbLen[1] = cbLen[2] = SQL_NTS; ret = SQLAllocHandle( SQL_HANDLE_STMT, m_hdbc, &m_hstmt ); ret = SQLPrepare( m_hstmt, qry.get(), SQL_NTS ); ret = SQLBindParameter( m_hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_WCHAR, m_maxIdLen, 0, catalog.get(), 0, &cbLen[0] ); ret = SQLBindParameter( m_hstmt, 2, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_WCHAR, m_maxIdLen, 0, schema.get(), 0, &cbLen[1] ); ret = SQLBindParameter( m_hstmt, 3, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_WCHAR, m_maxIdLen, 0, table.get(), 0, &cbLen[2] ); ret = SQLExecute( m_hstmt ); that code errors out with the error message "SQL syntax error near p2". Am I not allowed to arametrize this query like that? Thank you.92Views0likes1Comment“8152 String or binary data would be truncated” error while running select query on a view
I have a complex view (it’s organisational so i cannot paste it here) that joins multiple tables, uses CTEs, performs logical calculations and then provides for multiple columns over which we can select. This view is based on top of multiple master tables and a transactional table. It was performing fine until today morning. But then it started throwing 8152 error. I’m assuming it’s started happening only after certain values got written to the transactional table. The funny thing is, that the view is still executing fine if I remove just one column from the select query. If i include that one column in the select query, it throws 8152 error. I spent my entire day trying to troubleshoot, but couldn’t. Unable to understand how the view is running fine but the including a column in the select query causes it to malfunction. Any insights would be much appreciated.Solved48Views0likes1CommentBest Practice to migrate data via SFTP
Hi, I am currently working on a project that will be migrating part of an on-premise solution to the cloud (AWS). As a result, we are breaking the link of our reporting tool that feeds directly to the on-premise database (soon to be cloud based database). The database is a microsoft sql server and let's assume it is on a supported version (currently waiting for exact version). For this project, the only approved integration pattern for data transfer between on-premise and cloud is via SFTP. This is the integration pattern approved by architecture governance. We won't be able to connect our reporting tool to the now cloud to be DB (no direct-link, no vpn, etc). Understanding that SFTP may not be the most elegant solution, what would be the best way using Microsoft SQL Server features to produce file(s) that can be sent on-premise via sftp and use these to: 1.- Load directly to the reporting tool. or 2.- Use to populate a replica of the cloud DB on-premise. We would be interested in changes only (not dumping the entire DB every time). Given my limited knowledge on the technology, I can think of a differential backup, send it via sftp, restore on-premise. Have the backup scheduled for every x min? The deltas won't be gigabytes and they will actually be small (at least that is the expectation). Thanks3KViews0likes5CommentsTemporal Table - Change the ValidFrom Time
Sql Server 2022 - We needed a new 'Bonus' value to be active from 11/01/2025 06:00:00. I created a one time SQL job to update the temporal table for the Bonus value (going from 2.175 to 2.00) to run at 11/01/25 06:00:00. In the temporal table, the valid from is (converted to the local time) 2025-11-02 06:00:00.5656752 -06:00. If I pass FOR SYSTEM_TIME FROM '2025-11-02 06:00:00' TO '2999-01-01 23:59:59.999', I will get the previous since the job was just over a 1/2 second late. I've read articles talking about turn off versioning, then updating the History and current tables, then turning versioning back on. Seems like thats not possible with a generate always ValidFrom. I tried to create a temporal table where Validfrom as GENERATED BY DEFAULT but that didn't work. Is there a way I can get my validFrom to exactly 11/01/2025 06:00:00? Is there a better way in the future to get things set to exactly a desired time?142Views0likes2CommentsSQL Server 2025 – Native JSON Size Limit?
Hi Guys, I am exploring SQL Server 2025 to store JSON documents using the native JSON data type. I have gone through several Microsoft SQL technical documents but couldn’t find the maximum size of the native JSON data type. I believe it hasn’t been officially published yet. Does anyone have any insights? Thanks, Tushar102Views0likes1CommentSQL Server - Always On High Availability Group Setup
We have an Always On High Availability Group setup with three database servers — two on the same subnet and one on a different subnet. The application server interacts with these database servers through the AG listener. Currently, this setup is running with application version X, and we have received a new application version Y for upgrade/migration (which includes database changes). To perform the application update, please clarify the recommended approach: Should I remove the database from the Availability Group and point to the primary replica to continue with the application update? or Can I proceed with the application update while the Always On configuration remains active, pointing to the AG listener?111Views0likes1CommentQuery on sys.dm_db_index_usage_stats slow
Hi, we discovered that queries on sys.dm_db_index_usage_stats are getting very slowly when the sql server is running for a longer time without restart. The execution time is up to 30 seconds for the following query: SELECT object_name(object_id) objectName, last_user_update FROM sys.dm_db_index_usage_stats WHERE database_id=db_id() We get the following query plan: The Actual Rows in LOGINDEXSTATS are about 2 million. We found 2 similiar cases by searching the internet: https://stackoverflow.com/questions/52165370/query-against-sys-tables-sys-dm-db-index-usage-stats-slow https://www.linkedin.com/pulse/sql-server-2014-object-dependencies-dmvdmf-slow-andrea-bruschetta We tested the workaround (UPDATE STATISTICS sys.*** WITH FULLSCAN;) without success. How can we increase performance without restarting the database? Regards Dominik61Views0likes0Comments"ALTER DATABASE CURRENT SET ALLOW_SNAPSHOT_ISOLATION ON" does not finish for several hours
I have tried enabling snapshot isolation on several SQL Server instances (2017 and 2022 developer editions) in single user mode with the same huge DB (4 TB) but the command does not finish even after 6 hours... ALTER DATABASE CURRENT SET ALLOW_SNAPSHOT_ISOLATION ON Session is waiting on "ENABLE_VERSIONING" and I don't see any noticeable I/O activity on the Windows disk itself.49Views0likes0CommentsWhy is SQL Server only storing 4000 characters in an NVARCHAR(MAX) column?
Hi Guys, I'm trying to insert a string with 10,000 plain characters (just repeated 'A's) into a column defined as NVARCHAR(MAX) in SQL Server. But LEN(Content) always returns 4000, not 10,000. I’ve verified that the column is NVARCHAR(MAX) and used the N prefix for Unicode. Still, the data seems to be truncated. What could be causing this? Is there something I'm missing in how SQL Server handles large strings? Tried this: CREATE TABLE LargeTextExample ( Id INT PRIMARY KEY IDENTITY(1,1), Content NVARCHAR(MAX) ); DECLARE @LongText NVARCHAR(MAX); SET @LongText = REPLICATE(N'A', 10000); INSERT INTO LargeTextExample (Content) VALUES (@LongText); SELECT LEN(Content) AS CharacterCount FROM LargeTextExample; Thanks, TusharSolved150Views0likes2Comments
Events
Recent Blogs
- Alongside with the general availability of SQL Server 2025, SQL Server Integration Services is now generally available. Enterprise security Microsoft SqlClient Data Provider Support Microsoft....Nov 18, 2025365Views0likes0Comments
- SQL Server Management Studio 22 generally availability has been released. SSMS 22 GA version is recommended to use with Integration Services, as Integration Services 2025 is better supported and know...Nov 18, 2025282Views1like0Comments