Tags » Primary Key

SQL Server - Transact SQL - Specify Fill Factor when creating primary key

Background

Fill Factor is an important component to think of when creating an index.

It is pretty well known how to use the with clause to specify Fill Factor, targeted groups when creating an Index. 229 more words

Microsoft

SQL Server -Dump Info on Keys

Here’s a short stored procedure that could be useful when trying to understand a SQL Server database.

Let’s say that you have a simple schema like the one below.  471 more words

T-SQL

Primary Key

In this blog, we’ll discuss about  Primary key.

  1. Primary key is one of the most commonly in use constraint in MS SQL.
  2. Only 1 Primary key can be defined in a table.
  3. 753 more words
Constraints In SQL

Integrity Constraint in SQL

In this blog, we’ll discuss about Integrity constraint in SQL Server.

Integrity constraint are rules implemented in the tables to guarantee the accuracy, completeness, or consistency of data in tables and keep safe the business logic of the schema design.Constraints are part of a database schema definition… 105 more words

Constraints In SQL

How to identify Primary and foreign key column information in SQL Server

Here is a small script to get information about the Primary Key column(s) and Foreign Key column(s) in SQL Server.

Script:


;WITH GETINFO AS
(
	SELECT	DBNAME = CONVERT(SYSNAME,DB_NAME()), 
				OWNERNAME = CONVERT(SYSNAME,SCHEMA_NAME(OBJ1.SCHEMA_ID)), 
				 = CONVERT(SYSNAME,OBJ1.NAME), 
				PKCOLUMN_NAME = CONVERT(SYSNAME,COL1.NAME), 
				= CONVERT(SYSNAME,OBJ2.NAME), 
				FKCOLUMN_NAME = CONVERT(SYSNAME,COL2.NAME), 
				ORDINALPOSITION             = ISNULL(CONVERT(SMALLINT,FKCOL.CONSTRAINT_COLUMN_ID),0),
				 = CONVERT(SYSNAME,OBJECT_NAME(FK.OBJECT_ID)), 
				 = CONVERT(SYSNAME,I.NAME)
	FROM   SYS.ALL_OBJECTS OBJ1, SYS.ALL_OBJECTS OBJ2, SYS.ALL_COLUMNS COL1, SYS.ALL_COLUMNS COL2, SYS.FOREIGN_KEYS FK 
	INNER JOIN SYS.FOREIGN_KEY_COLUMNS FKCOL ON (FKCOL.CONSTRAINT_OBJECT_ID = FK.OBJECT_ID) 
	INNER JOIN SYS.INDEXES I  ON (FK.REFERENCED_OBJECT_ID = I.OBJECT_ID AND FK.KEY_INDEX_ID = I.INDEX_ID) 
	WHERE  OBJ1.OBJECT_ID = FK.REFERENCED_OBJECT_ID AND OBJ2.OBJECT_ID = FK.PARENT_OBJECT_ID 
				AND COL1.OBJECT_ID = FK.REFERENCED_OBJECT_ID AND COL2.OBJECT_ID = FK.PARENT_OBJECT_ID 
				AND COL1.COLUMN_ID = FKCOL.REFERENCED_COLUMN_ID AND COL2.COLUMN_ID = FKCOL.PARENT_COLUMN_ID
),SHOWINFO AS
(
	SELECT DISTINCT DBNAME,OWNERNAME,,,
           PRIMARYKEYCOLUMNNAMES=  REPLACE( 
			   (SELECT A.PKCOLUMN_NAME AS 
				FROM GETINFO A
				WHERE A. 94 more words
SQL Server

Need the Rain

I must confess that is true.
When the smoky haze fall and block your eyes, there’s no a light follows you there.
you’re lost, you need the rain to clear haze. 18 more words

Primary Key

Codd's Normalization - 1NF,2NF and 3NF explained

Normalization can be defined as a systematic approach of organizing table and its columns in such a way to reduce redundancy and ensure data dependency by integrity constraints… 386 more words

Sql