Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Script error in SQL Svr 2008 and not in 2008 R2

$
0
0

I am working on 2 different servers one of which has SQL Server 2008 and the other has SQL Server 2008 R2.  I have a reindexing script that works on the R2 version but will not run on the plain 2008 version.  See the 2 code chunks below. Can anyone tell me why the bold lines are OK in the R2 version but not in the non-R2 version.  Both error messages say "Incorrect syntax near '('." and go to the 2Bold lines when double-clicked.

select s.name,o.name,i.name,ips.avg_fragmentation_in_percent from sys.objects o left outer join sys.schemas s on
o.schema_id = s.schema_id  left outer join sys.indexes i on
o.object_id = i.object_id left outer join sys.dm_db_index_physical_stats (db_id(), NULL, NULL, NULL, NULL) AS ips
on i.object_id = ips.object_id and i.index_id = ips.index_id
where o.type = 'U' and i.index_id > 0 and avg_fragmentation_in_percent between 5 and 30

select s.name,o.name,i.name,ips.avg_fragmentation_in_percent from sys.objects o left outer join sys.schemas s on
o.schema_id = s.schema_id  left outer join sys.indexes i on
o.object_id = i.object_id left outer join sys.dm_db_index_physical_stats (db_id(), NULL, NULL, NULL, NULL) AS ips
on i.object_id = ips.object_id and i.index_id = ips.index_id
where o.type = 'U' and i.index_id > 0 and avg_fragmentation_in_percent > 30

Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>