select @@servernameASServerName
Select @@VERSIONAsSQLServerVerjion
go
selectserverproperty(‘Edition’)AsServerEdition
selectserverproperty(‘ProductLevel’)ServerProductLevel
selectserverproperty(‘BuildClrVersion’)BuildVersion
select @@servernameASServerName
Select @@VERSIONAsSQLServerVerjion
go
selectserverproperty(‘Edition’)AsServerEdition
selectserverproperty(‘ProductLevel’)ServerProductLevel
selectserverproperty(‘BuildClrVersion’)BuildVersion
CREATE TABLE TPA
(ID INT , [NAME] NVARCHAR(50))
GO
INSERT TPA VALUES (1,’MOSTAFA’)
INSERT TPA VALUES (2,’ELMASRY’)
BEGIN TRY
— Generate a divide-by-zero error.
SELECT ID+[NAME] FROM TPA
END TRY
BEGIN CATCH
SELECT * FROM TPA
END CATCH;
GO
BEGIN TRY
— Generate a divide-by-zero error.
SELECT ID+[NAME] FROM TPA
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
GO
Before you run this script
USE [master]
GO
ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE <dbname> SET SINGLE_USER
GO
DBCC CHECKDB <dbname>, REPAIR_REBUILD) WITH ALL_ERRORMSGS, NO_INFOMSGS
GO
ALTER DATABASE <dbname> SET MULTI_USER
GO
Or
Take Care From this Script becouse it will make repaire and may be some Data will loss
EXEC sp_resetstatus ‘yourDBname’;
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb(‘yourDBname’)
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (‘yourDBname’, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER
I do this steps in my SQL Server 2012 and you can make this steps in Any version like 2005 – 2008 – 2008 R2 Also To remove or Add or repaire SQL Server :
1- Go to Programe and Feature
2- Select your SQL Server name
3- Write click on the name and select Uninstall
4- If you want to add New instance or to add New feature to exsiting instance select Add , Also if you want to repair your instance select the Second Choice Repair
5- in this example we will select Remove
5- After this step we will select the instance you want to remove it or you want to remove some feature from this instance

6- After this step clic Next to determine if you want to remove the instance of the whole or to remove Feature from this insance if you want to remove the instance sellect all thisng in the Screen , Else select the feature you want to be remove it .
7- After you determine waht you Need . make Next to make SQL Sever Check your role may be if you reomve this instance SQL Server will give you Error or Warning so this step is very imporatnt
8- Then Click Next to tell SQL Sever you are Arealdy to remove your Selected
9- after this step if you click Next SQL Server will reove your Selected so i think you must be Retreat yourself becouse the Next step is final {There is no room to return} if you want Click next if you Retreated yourself click cansel.
sorry i cant complete with you the final Step becouse i Retreated my self and i discovered i love Microsoft and i cant reove any tool from microsoft so Complete this step Alone
Good Luck
best Regardes
Mostafa Elmasry
This Feature in SQL Server 2008 , 2012
USE master
Go
EXEC sys.sp_configure N’backup compression default’, N’1’
GO
RECONFIGURE WITH OVERRIDE
GO