We had a situation where we need to disable all the build definitions, build controllers and build agents without bringing TFS up and running. This was on QA instance, we backed up and restored the database on QA from Prod, so when we brought QA TFS up, TFS QA started running all the scheduled builds on Prod build controllers, which caused the problem.
Here are the SQL commands I ran on TFS QA database, which disabled all the 600+ build definitions and 100+ controllers
Use TFS_<Collection Name>
--Disable Build Agents
Update dbo.tbl_BuildAgent Set [Enabled]= 0 Where [Enabled]=1
Update dbo.tbl_BuildController Set [Enabled]= 0 Where [Enabled] =1
--Disable Build definitions
Update dbo.tbl_BuildDefinition Set [Enabled]= 0 Where [Enabled] =1