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
4
votes
1 answer

DBCC SHRINKFILE failing

I'm trying to shrink a database on a test system but the file won't get any smaller. The size of the mdf file is 47 GB and unused space is 38 GB. A lot of data was removed from the database hence the large amount of unused space. The following…
Guido Neele
  • 778
  • 1
  • 7
  • 20
4
votes
1 answer

How safe is to clear Wait stats

I have been facing performance issues in the production server; and while reading it about on internet I came across @Brent Ozar article about wait stats. I want to try that but I am not sure how safe is it to run. My production environment is…
Zerotoinfinity
  • 6,290
  • 32
  • 130
  • 206
4
votes
5 answers

DBCC shrinkfile gives error

I am trying to shrink my log file using DBCC SHRINKFILE(db_2.ldf), which is the name for log file It gives me error every time: 8985, Level 16, State 1, Line 1 Could not locate file 'FIelD' for database db in sys.database_files. The file either…
user70636
  • 1,029
  • 3
  • 12
  • 13
4
votes
1 answer

What (kind of) data is lost when using REPAIR_ALLOW_DATA_LOSS?

after having some trouble with my sql server 2012 I could only fix the data inconsistencies using DBCC CHECKDB (xxx, REPAIR_ALLOW_DATA_LOSS). The option's name implies, that there will (possibly) be a data loss, when the database is repaired. What…
Sascha
  • 1,210
  • 1
  • 17
  • 33
4
votes
2 answers

Get last command in SQL Server without DBCC INPUTBUFFER

Is there a way to get the last executed SQL Server command without the use of DBCC INPUTBUFFER? For example, is there a System View or Catalog that contains this information? Thanks.
Neil Weicher
  • 2,370
  • 6
  • 34
  • 56
4
votes
1 answer

How to find the changed delta value for update transaction after rollback is done in transaction log in SQL Server

I am trying to understand the internals of tranaction log of mssql. I do a following transaction Begin TRANSACTION update xyz1 set a=6 Rollback TRANSACTION Initially value of column 'a' is 5 . So the result of the transaction was found to be as…
3
votes
1 answer

Reset Identity Seed ('DBCC CHECKIDENT ... RESEED' is not working)

For my unit tests I have an automated process which builds a copy of a DB, table by table. I first of all run a SELECT INTO and add the primary key and any indices. Some of the tables I copy with data, and for those without data I wish to reset the…
awj
  • 7,482
  • 10
  • 66
  • 120
3
votes
2 answers

DBCC CHECKIDENT can't find the table

I have table that has an id which both an identity AND primary key of a table. When run this Use devdb Select * from tablename order by did desc works and I see the data. When I run the following, I see the table in list Use devdb SELECT * FROM…
Zuzlx
  • 1,246
  • 14
  • 33
3
votes
1 answer

Executing DBCC Command From ADO.Net

I am trying to execute DBCC CHECK DB('MyDB) using ADO.Net, but how can I get the text returned by the command? I have tried the following: SqlCommand sqlCom = new SqlCommand("DBCC CHECKDB ('MyDB')", sqlCon); SqlParameter output = new…
jaffa
  • 33
  • 1
  • 3
3
votes
1 answer

Migrate SQL Server database to multiple files

I have a SQL Server 2008 database in production that we are moving onto a new server. The current database has a single ~400GB .MDF file. The new server will be running SQL Server 2012, and we are running mirrored Intel 910 SSDs. These drives will…
2
votes
4 answers

Is there a way to run sys.dm_db_log_space_usage for all databases?

I'm looking to create a monitoring tool to track changes in transaction log usage on a production server we maintain. Previously, I used DBCC SQLPERF(LOGSPACE);, which provided a list of all databases and their current transaction log memory status.…
2
votes
1 answer

Is DBCC command a stored procedure or a function?

What should be the DBCC commands be called ? DBCC procedure or DBCC function? It is confusing because DBCC PAGE could be executed without prefixing a EXEC statement much like stored procedures. But EXEC DBCC PAGE(1,1,1,3) throws an error Syntax…
LonelyRogue
  • 376
  • 1
  • 2
  • 10
2
votes
1 answer

Sql Server page structure. What is Fdata length?

I am trying to understand the structure of the Sql Server data pages. This is the screenshot from the Pro SQL Server Internals by Dmitri Korotkevitch I've created 3 tables: 1 INT Column 2 INT Columns 4 INT Columns All columns are NOT NULL Then I…
Dmitrij Kultasev
  • 5,447
  • 5
  • 44
  • 88
2
votes
2 answers

Does reset primary keys with DBCC CHECKIDENT safe for rows with bigger Id

I have a table with primary integer key value and its auto increment one by one , the values inside were going fine until 116, suddenly after a moment it continues from 10085 value .. I don't know why but maybe I did a shrink database. But anyway I…
Mazdak
  • 771
  • 2
  • 11
  • 24
2
votes
2 answers

DBCC Command Not Working Inside Procedure

I have below query. Logically, the procedure usp_mytran should RESEED the Identity to 1 for table dbo.Sales. But the last query is returning different values for Max_ID_Value and Current_Seed_Value. Can anyone please explain why DBCC command is not…
Ajay Dwivedi
  • 328
  • 2
  • 14