Friday 10 May 2013

useful links

Full Text Catalogs

http://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/

INSTEAD OF TRIGGERS

http://msdn.microsoft.com/en-us/library/ms175521.aspx

Synonyms

http://msdn.microsoft.com/en-us/library/ms177544.aspx

Thursday 2 May 2013

SQL - A surprise!!!


DECLARE @ToCreate bit
IF @ToCreate = 1
DECLARE @Table TABLE
    (id int, name varchar(50) )
ELSE
    INSERT INTO @Table (id, name)
    select 1, 'a'
SELECT * FROM @Table

Variables, including table variables, are initialised during parsing time, not run time. Run-time flow control logic does not apply to DECLARE statements. @Table is created during the batch compilation and gets populated in run-time, as per flow control logic (@ToCreate is NULL, ELSE part is executed).

SQL - Identity Insert

Below is a table which has one column with identity property. How do I insert values in this table without changing the identity property of the column?

CREATE TABLE TableA(ID INT IDENTITY(1,1))

Ans:INSERT INTO TableA DEFAULT VALUES