Forum Widgets
Latest Discussions
Failure 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.oneeyeman1Nov 14, 2025Copper Contributor17Views0likes0Comments“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.SolvedSwaTHasSasINNov 13, 2025Occasional Reader19Views0likes1CommentBest 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). ThanksNullPointahNov 10, 2025Copper Contributor2.9KViews0likes5CommentsTemporal 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?BartNSTCLNov 10, 2025Copper Contributor54Views0likes2CommentsSQL 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, TushartuspatilNov 08, 2025Copper Contributor75Views0likes1CommentSQL 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?VarmanNov 03, 2025Copper Contributor44Views0likes1CommentQuery 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 DominikDominikSOct 31, 2025Copper Contributor44Views0likes0Comments"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.yonisadeOct 29, 2025Copper Contributor33Views0likes0CommentsWhy 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, TusharSolvedtuspatilOct 28, 2025Copper Contributor110Views0likes2Comments
Resources
Tags
- Data Warehouse71 Topics
- sql server67 Topics
- Integration Services64 Topics
- sql52 Topics
- Reporting Services45 Topics
- Business Intelligence41 Topics
- Analysis Services33 Topics
- analytics23 Topics
- Business Apps23 Topics
- ssms16 Topics