I'm running different scripts from SQLFOOL & SQL Authorities an etc. but when I check the database I cannot see any defragmentation at all. I wrote a bit code which is not working, could you please give me a hand?
Declare @table_name Varchar (70);
Declare table_cursor Cursor for
select OBJECT_SCHEMA_NAME([OBJECT_ID])+'.' + NAME AS Tablenamee
from sys.tables
open table_cursor
Fetch next from table_cursor into @table_name
While @@fetch_status = 0
begin
Alter index all on @table_name
REBUILD WITH (FILLFACTOR=80, ONLINE=ON)
fetch next from table_cursor into @table_name
end
Close table_cursor
deallocate table_cursor
Getting error
incorrect syntax near @table_name