-
Alter Index - Syntax Mssql 2005
Please help---sql doesn't like me using a variable in the following statement.
declare @tblName varchar(30)
set @tblName = 'tblFOO'
ALTER INDEX ALL ON @tblName
REBUILD WITH (FILLFACTOR = 80,
ONLINE = ON, SORT_IN_TEMPDB = ON,
STATISTICS_NORECOMPUTE = OFF)
receive the following error:
Incorrect syntax near '@tblName'.
-
Need dynamic sql, try this:
exec ('ALTER INDEX ALL ON ' + @tblName
+ ' REBUILD WITH (FILLFACTOR = 80,
ONLINE = ON, SORT_IN_TEMPDB = ON,
STATISTICS_NORECOMPUTE = OFF)
')
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|