Questions tagged [dbcc]

DBCC stands for Database Console Commands in Transact-SQL.

The Database Console Commands (DBCC) are a series of statements in Transact-SQL programming language to check the physical and logical consistency of a Microsoft SQL Server database. These commands are also used to fix existing issues. They are also used for administration and file management.

DBCC was previously expanded as Database Consistency Checker.

Source: Wikipedia (Database Console Commands)

106 questions
0
votes
0 answers

Creating table with different columns depending on condition (which is SQL version)

I would like to create a table for statement: DBCC CHECKDB (0) WITH ALL_ERRORMSGS, TABLERESULTS however the result of this statement depends on SQL Server version, in higher versions there are more columns. Statement: IF…
I.P.
  • 300
  • 2
  • 16
0
votes
2 answers

If DBCC printed error messages, contact your system administrator: operand type clash on index rebuild

Question: I'm using SQL Server 2016 and have a table with encrypted columns using Always Encrypt. I had to make some changes to the table. So, I had to drop and re-add the table. The table has one index, the clustered index. When I rebuild my…
rednelo
  • 3
  • 3
0
votes
2 answers

Weird behavior of DBCC CHECKIDENT with RESEED in a rolled-back transaction

Consider the following T-SQL code (the code is available along with an ADO.NET version in this GitHub repo https://github.com/PaloMraz/SqlServerReseedSampleApp): DROP TABLE IF EXISTS __Test; CREATE TABLE __Test (Id INT IDENTITY NOT NULL PRIMARY…
Palo Mraz
  • 625
  • 5
  • 16
0
votes
1 answer

Why Row Locks Exist on An Completely Empty Partition in SQL Server?

I made a partitioned table with range left func. I then insert some rows into just one partition. Result: select partition_id, partition_number, rows from sys.partitions where object_id = object_id('ptest') result: partition_id …
chenwq
  • 123
  • 1
  • 11
0
votes
0 answers

Are there any .NET API to read SQL Server data pages?

I'm writing a C# program and it needs to read SQL Server data pages. Right now what I'm doing is using SQL Server's DBCC PAGE command to get this information and then parse the result. When the page number is huge, the performance is not very good.…
Just a learner
  • 26,690
  • 50
  • 155
  • 234
0
votes
1 answer

DBCC SHOWCONTIG returns 2 rows against certain tables

When I am running DBCC SHOWCONTIG ('schema_name.table_name') WITH TABLERESULTS, ALL_INDEXES, NO_INFOMSGS in SQL Server 2016 it is returning 2 rows against certain tables Example below: ObjectName ObjectId IndexName IndexId Level Pages Rows…
0
votes
2 answers

DBCC CHECKDB did not return a result set in Java ( MS SQL )

Here is my Function: private static void checkDatabase(String dbName, String password) { try{ Connection con=DriverManager.getConnection( "jdbc:sqlserver://localhost;database="+dbName+ ";user=SA;password=" +password); …
0
votes
1 answer

SQL Server :: FULL backup not recorded in msdb.dbo.backupset and log file unusually large

I have a server that is running SQL Server 2019 but the databases are still on Compatibility level 110 (so that means SQL Server 2012 basically). We take a FULL backup every night and I indeed see the files backed up in the right folder every day.…
Francesco Mantovani
  • 10,216
  • 13
  • 73
  • 113
0
votes
1 answer

Capture content from Messages Tab SSMS

I am running the following query to shrink logfile of a database. DBCC shrinkfile('Sample_log',0) My concern is that, even if shrinking fails, query will run without any error. Only a message will be shown in message tab. And this error cannot be…
0
votes
0 answers

Sql Database giving error message while running DBCC CHECKDB()

Please assist, While running DBCC checkdb() on my production server I am getting below error. Msg 8921, Level 16, State 1, Line 1 Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is…
Mayank
  • 23
  • 1
  • 2
  • 9
0
votes
1 answer

What is SQL Server's DBCC SHRINKFILE T-SQL command equivalent for UI option "‘Reorganize pages before releasing unused space"

Am trying to find if there's any equivalent option DBCC SHRINKFILE T-SQL command for the option "Reorganize pages before releasing unused space" that is seen when performing through SSMS. The usual TRUNCATEONLY/TargetSize options does reduce the…
LonelyRogue
  • 376
  • 1
  • 2
  • 10
0
votes
1 answer

Can't Run DBCC CHECKDB on master DB - Azure Files

Storing SQL Server database files on new Azure Files share. Cannot run full / comprehensive CHECKDB against these databases - I think this has something to do with user account not having permissions to create snapshots. As a result, I offloaded…
BBaggins
  • 3
  • 3
0
votes
0 answers

How to get DateTime stamp from SQL Server DBCC LOG transaction?

I'm using SQL Server 2008 'DBCC LOG(database, 4)' to see a view of transactions in question but do not see a DateTime stamp associated with them. Any idea how to retrieve the Time stamp of a particular transaction?
GregP
  • 143
  • 12
0
votes
1 answer

T-SQL how to get more than last query executed by SPID from the cache (DBCC INPUTBUFFER, sys.sysprocesses)

I have this scenario: SPID = 100 (A SSMS tab for example) SELECT TOP 1 * FROM SOME_TABLE GO SELECT TOP 1 * FROM SOME_TABLE2 GO SELECT TOP 1 * FROM SOME_TABLE3 When I run (DBCC INPUTBUFFER, sys.sysprocesses), I got only the last query executed: …
ricardo347
  • 13
  • 4
0
votes
1 answer

DBCC command to reseed identity of table inside Execute SQL Task in SSIS

I have a situation in which a fact table is loaded every day. There are two SSIS packages that load this table. 1) Package1_FullLoad.dtsx - runs every Sunday, with a full refresh 2) Package2_DailyLoad.dtsx - runs on all days except Sundays, deleting…
user3812887
  • 439
  • 12
  • 33