Using DBCC UPDATEUSAGE to correct inaccuracies(Copy from another blog)


The DBCC command can be run on a database to correct inaccuracies of all objects in that database or you can also correct the inaccuracies of a single table by including that table name. If you would like to run the command for a particular database, then you can run the following command

DBCC UPDATEUSAGE (‘DATABASENAME’)

You can also run the below command to correct the inaccuracies for the current database

DBCC UPDATEUSAGE (0)

Remarks : I take this Information Copy from this Blog : http://learnsqlwithbru.com/2012/02/02/using-dbcc-updateusage-to-correct-inaccuracies/

Ole Automation Procedures to delete file from PC


if you want to write Script to delete file from  your pc by SQL Server must be Configure your SQL server to allow this option :

exec sp_configure ‘Ole Automation Procedures’, 1

go

reconfigure

go

 

Change The Server Collation after installation


After you finish installation for SQL server may be you want to change the Server collation or database Collation so leat’s see what will we do if we want to make this :

1- if you want to know what’s your database collation know

SELECT name, collation_name

FROM sys.databases WHERE name = ‘test’   — put your database name here

2- If you want to get a list of all available collations on the server using

SELECT * FROM ::fn_helpcollations()

3- Alter Database Collation

ALTER DATABASE test           — put your database name here

COLLATE Arabic_CI_AS        — replace with whatever collation you need

4- IF you want to know what’s your server collation

SELECT SERVERPROPERTY (‘Collation’)

Enable xp_cmdshell using sp_configure


—- To allow advanced options to be changed.

EXEC sp_configure ‘show advanced options’, 1

GO

—- To update the currently configured value for advanced options.

RECONFIGURE

GO

—- To enable the feature.

EXEC sp_configure ‘xp_cmdshell’, 1

GO

—- To update the currently configured value for this feature.

RECONFIGURE

GO

Configure SQL Server Agent XPs


To Enable Agent XPs

sp_configure ‘show advanced options’, 1;

GO

RECONFIGURE;

GO

sp_configure ‘Agent XPs’, 1;

GO

RECONFIGURE

GO

To disable Agent XPs

sp_configure ‘show advanced options’, 0;

GO

RECONFIGURE;

GO

sp_configure ‘Agent XPs’, 0;

GO

RECONFIGURE

GO