开发者

Dynamic SQL Execution

开发者 https://www.devze.com 2023-03-01 23:18 出处:网络
Im开发者_C百科 not able to execute below query.Please help. Declare @i Int Set @i=1 Exec(\'Createindextind\'+convert(varchar(20),@i)+\' on product(qty)\')

Im开发者_C百科 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)')


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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号