Skip to main content

Posts

DBCC CHECKTABLE

Checks the integrity of all the pages and structures that make up the table or indexed view. Syntax: DBCC CHECKTABLE ( table_name | view_name [ , { NOINDEX | index_id } |, { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD } ] ) [ WITH { ALL_ERRORMSGS ] [ , EXTENDED_LOGICAL_CHECKS ] [ , NO_INFOMSGS ] [ , TABLOCK ] [ , ESTIMATEONLY ] [ , { PHYSICAL_ONLY | DATA_PURITY } ] [ , MAXDOP = number_of_processors ] } ] DBCC CHECKTABLE( 'Production.Product' )

DBCC Command (Database Consistency Checker) -Sql Server

Database Consistency Checker act as Database Console Commands give details in form of statistics about the SQL Server. They can be used for Maintenance of database, index, or file group. DBCC Commands can be used to perform validation operations on a database, table, index, catalog, file group, or allocation of database pages. Database Console Command statements are grouped into the following categories. Maintenance   :  Maintenance tasks on a database, index, or filegroup. Miscellaneous  :  Miscellaneous tasks such as enabling trace flags or removing a DLL from memory. Informational  :  Tasks that gather and display various types of information. Validation         :  Validation operations on a database, table, index, catalog, filegroup, or allocation of database pages. DBCC Internal Database Snapshot command  DBCC CHECKALLOC DBCC CHECKDB DBCC CHECKCATALOG DBCC CHECKFILEGROUP DB...

Split a string to a table using T-SQL

  In this tutorial, I will create a utility function used for string split and return in a table. ALTER FUNCTION Splitstring_to_table ( @string NVARCHAR( MAX ), @ delimiter CHAR ( 1 ) ) RETURNS @ output TABLE ( id INT IDENTITY ( 1 , 1 ) PRIMARY KEY , data NVARCHAR( MAX ) ) BEGIN DECLARE @ start INT , @ end INT SELECT @ start = 1 , @ end = CHARINDEX(@ delimiter , @string) WHILE @ start < LEN(@string) + 1 BEGIN IF @ end = 0 SET @ end = LEN(@string) + 1 INSERT INTO @ output ( data ) VALUES ( SUBSTRING (@string, @ start , @ end - @ start )) SET @ start = @ end + 1 SET @ end = CHARINDEX(@ delimiter , @string, @ start ) END RETURN END push string to function, see result SELECT * FROM dbo.Splitstring_to_table( 'Bangladesh, America, German,' , ',' ) Charindex : In SQL Server (Transact-SQL), the CHARINDEX function...

Generate HASH string with T-SQL -Sqlserver

Using   HASHBYTES   Generate HASH string : HASHBYTES ( '<algorithm>' , { @ input | 'input' } ) <algorithm>::= MD2 | MD4 | MD5 | SHA | SHA1 | SHA2_256 | SHA2_512   Algorithm  MD5:   SELECT   CONVERT ( VARCHAR (32),   HashBytes ( 'MD5' ,   'code-lake@blogspot.com' ),2) Output:   7A598B534FD42DF41F7725CAAD261DCB Algorithm SHA1:   SELECT CONVERT(VARCHAR(32), HashBytes('SHA1', 'code-lake@blogspot.com'),2) Output:   7141CCD5A09B915B8541D4E4C3DCD108 Reference: MSDN