Create dynamic sql from user name and date
3>
4> DECLARE @sqlstring varchar(100)
5> SELECT @sqlstring = 'SELECT * FROM ' + LTRIM(user_name()) +
6> CONVERT(char(2),DATEPART(dd, GETDATE()))
7> EXEC (@sqlstring)
8> GO
Msg 208, Level 16, State 1, Server J\SQLEXPRESS, Line 1
Invalid object name 'dbo17'.
Related examples in the same category