February 11, 2015

How to Disable and Enable All Constraint for Table / Database

To enable or disable all the constraint for single table or database.


-- Disable all table constraints
ALTER TABLE YourTableName NOCHECK CONSTRAINT ALL
-- Enable all table constraints
ALTER TABLE YourTableName CHECK CONSTRAINT ALL
-- Disable single constraint
ALTER TABLE YourTableName NOCHECK CONSTRAINT YourConstraint
-- Enable single constraint
ALTER TABLE YourTableName CHECK CONSTRAINT YourConstraint
-- Disable all constraints for database
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
-- Enable all constraints for database
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

December 27, 2014

MS SQL 2005 : To Check the size of the Database

Use the Below Query to Check the Database Size with all *.mdf & log.*ldf file sizes

****QUERY****

SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeMB
FROM sys.master_files
WHERE DB_NAME(database_id) = 'Database_Name'
Size of DB - shyamb4u

December 17, 2014

Generating CSV file using SQL Server 2005

A lot of times it is our inability to learn some of the simple techniques present in the tools that we use make us even more productive.

Here are the steps to achieve the same. 

Go to SQL Server Management Studio ---> Choose Tools from Menu Bar 
--> Click on Options.
 Go to “Query Results” ---> “SQL Server” ---> Click on “Results to Text”
shyamb4u

December 6, 2014

Learn Access 2007 in 30 Days.

Access 2007 is the database software in the Microsoft 2007 Office suite that allows you to order, manage, search, and report large amounts of information.

The below link provides complete source and learning process of Access 2007

CLICK TO DOWNLOAD - Access 2007

November 24, 2014

What is SCHEMABINDING?

SCHEMABINDING with a Query...

***Table***

CREATE TABLE Sampletbl ( col1 DATETIME ) 

***Data***

INSERT  INTO Sampletbl
VALUES  ( GETDATE() + 1 )

***Function***

CREATE FUNCTION SampleFunction ( )
RETURNS DATETIME
    WITH SCHEMABINDING
AS 
    BEGIN 

        DECLARE @t DATETIME

        SELECT  @t = col1
        FROM    dbo.Sampletbl

        RETURN @t

    END

November 21, 2014

MS SQL - Standby Servers and Types of Standby Servers

Standby servers - Standby Server is a type of server that can be brought online in a situation when Primary Server goes offline and application needs continuous (high) availability of the server. There is always a need to set up a mechanism where data and objects from primary server are moved to secondary (standby) server. This mechanism usually involves the process of moving backup from the primary server to the secondary server using T-SQL scripts. Often, database wizards are used to set up this process.

Languages for BI – MDX, DMX, XMLA

BI stands for Business Intelligence 

What languages BI uses to achieve the goal? 

MDX – Multidimensional Expressions. This language is used for retrieving data from SSAS cubes. It looks very similar to T-SQL, but it is very different in the areas of conceptualization and implementations.

DMX – Data Mining Extensions. This is again used for SSAS but rather than cubes it is used for data mining structures. This language is more complicated than MDX. Microsoft has provided lots of wizards in its BI tools, which further reduced experts for learning this language which deals with data mining structures.

XMLA – XML for Analysis. This is mainly used for SSAS administrative tasks. It is quite commonly used in administration tasks such as backup or restore database, copy and move database or learning meta data information. Again, MS BI tools provide lots of wizards for the same.