Reputation: 931
Im not able to execute below query.Please help.
Declare @i Int
Set @i=1
Exec ('Create index tind'+convert(varchar(20),@i)+ ' on product(qty)')
Upvotes: 0
Views: 76
Reputation: 432261
You can't have an expression as the EXEC argument. Do the dynamic SQL first
Declare @i Int, @sql varchar(1000)
Set @i=1
Set @sql = 'Create index tind'+convert(varchar(20),@i)+ ' on product(qty)'
Exec (@sql)
Upvotes: 3