参考资料:https://stackoverflow.com/questions/22008859/the-name-is-not-a-valid-identifier-error-in-function
执行存储过程中sql字符串:
SET @Name = 'select UserName from [' + @dbName + '].dbo.Users where UserID=' + CONVERT(VARCHAR, @UserID) exec(@Name)