About Me

My photo
MCTS FOR SQL SERVER 2008 DOT NET PROGRAMMING WEB DESIGNING

Saturday, 7 January 2012

earn money from home

are you interested to work from home......i will gove u one of the finest place to do so.....

http://www.sbrservices.in/ .......unbeleivabale services @ cheap rates...........no hidden charges......no registration fees.....get 3-10% discount in all recharges(mobile, DTH, hotels flights....and many more

THOUGH FOR THE DAY

BE PASSIONATE ABOUT UR WORK, TONNES OF KNOWLEDGE WILL AUTOMATICALLY COME....

Friday, 6 January 2012

how to delete indexes at a time?

the syntax is

declare @qry nvarchar(max);
select @qry =
(SELECT  'DROP INDEX ' + ix.name + ' ON ' + OBJECT_NAME(ID) + '; '
FROM  sysindexes ix
WHERE   ix.Name IS NOT null and ix.Name like '%prefix_%'
for xml path(''));
exec sp_executesql @qry

how to delete constraints?

here am giving the syntax to delete the constraints

Declare @TABLENAME varchar(max), @COLUMN varchar(max)
SET @TABLENAME = 'YOURTableName'
SET @COLUMN = 'YOURColumnName'
Declare @CONSTRAINT varchar(max)
                    set @CONSTRAINT ='ALTER TABLE '+@TABLENAME+' DROP CONSTRAINT '
                    set @CONSTRAINT = @CONSTRAINT + (select SYS_OBJ.name as CONSTRAINT_NAME
                    from sysobjects SYS_OBJ
                    join syscomments SYS_COM on SYS_OBJ.id = SYS_COM.id
                    join sysobjects SYS_OBJx on SYS_OBJ.parent_obj = SYS_OBJx.id
                    join sysconstraints SYS_CON on SYS_OBJ.id = SYS_CON.constid
                    join syscolumns SYS_COL on SYS_OBJx.id = SYS_COL.id
                    and SYS_CON.colid = SYS_COL.colid
                    where
                    SYS_OBJ.uid = user_id() and SYS_OBJ.xtype = 'D'
                    and SYS_OBJx.name=@TABLENAME and SYS_COL.name=@COLUMN)
                    exec(@CONSTRAINT)
--alter table <your tblename> drop column <your column name>