When i write a dynamic sql like this?
set @dynamicSQL='select '+@logName+'= name from '+@databaseName+'.sys.sysfiles where groupid=0'
It can't work,but when i write like this:
select @logName=name from sys.sysfiles where groupid=0;
It can work properly,and like this:
set @dynamicSQL='select name from '+@databaseName+'.sys.sysfiles where groupid=0'
It can work normal.But why? i will approciate If someone tell me.