Hello,
How come when I run the following batch it gives me an error?
GO
CREATE PROC dbo.sp_FixIndexFragRebuild @table varchar(40), @index varchar(40)
AS
BEGIN
IF (@index is Null)
ALTER INDEX ALL ON @table REBUILD
ELSE
ALTER INDEX @index ON @table REBUILD
END
GO
Error:
Msg 102, Level 15, State 1, Procedure sp_FixIndexFragRebuild, Line 5
Incorrect syntax near '@table'.
Thank you very much
How come when I run the following batch it gives me an error?
GO
CREATE PROC dbo.sp_FixIndexFragRebuild @table varchar(40), @index varchar(40)
AS
BEGIN
IF (@index is Null)
ALTER INDEX ALL ON @table REBUILD
ELSE
ALTER INDEX @index ON @table REBUILD
END
GO
Error:
Msg 102, Level 15, State 1, Procedure sp_FixIndexFragRebuild, Line 5
Incorrect syntax near '@table'.
Thank you very much