Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 run query

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2013-11-12 : 01:37:30
how do i execute this query (i try to insert it in parameter varchar(max) but it small?

select 'alter index ' +i.name+ ' on ' +o.name+ ' disable ' + CHAR(13)+Char(10)+';'
From sys.indexes i
Inner Join sys.objects o
On o.object_id = i.object_id
Where o.is_ms_shipped = 0
And i.index_id >= 1
AND o.NAME LIKE '%Fact%'

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-12 : 01:38:41
COPY the RESULT of this QUERY and PASTE into a new QUERY WINDOW and EXECUTE


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

inbs
Aged Yak Warrior

860 Posts

Posted - 2013-11-13 : 02:42:02
but i want to run it in the job
thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-13 : 04:13:27
[code]declare @sql nvarchar(max)

select @sql = isnull(@sql, '') + 'alter index ' +i.name+ ' on ' +o.name+ ' disable ' + CHAR(13)+Char(10)+';'
From sys.indexes i
Inner Join sys.objects o
On o.object_id = i.object_id
Where o.is_ms_shipped = 0
And i.index_id >= 1
AND o.NAME LIKE '%Fact%'
exec (@sql)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -