I think SQL Server before executing the query, check or compile it, for example, it checks the correctness of the table as follows:
select * from sys.objects where name = N'Dataarchive'
It will not have a result. instead for other modes that return the result.
Because of this, it will rise:
Invalid object name 'Dataarchive'.
But you can check sys.object another COLLATION as follows:
select * from sys.objects where name COLLATE latin1_General_CI_AI = N'Dataarchive'
This will produce the result, AFAIK, you cannot force the SQL Server DBMS to check it or compile it as follows.
BTW, you can get the table data in this case - using Dynamic SQL - like this:
declare @tablename nvarchar(255) = 'Dataarchive'; declare @sql nvarchar(255) = N'SELECT * FROM '+ ( select name from sys.tables where name = @tablename COLLATE Latin1_General_CI_AI); exec sp_sqlexec @sql;
source share