First I was getting this error:
Invalid object name "product_images​_temporary"
and after I have added the []
brackets, everything worked fine. But then when I removed them again, I got this error:
Incorrect syntax near '​'
Why does this work:
[product_images​_temporary]
but this throws an exception ("Incorrect syntax near '​'"):
product_images​_temporary
More code:
try
{
using (var sqlConnection = new DapperHelper().DatabaseConnection())
{
var sqlStatement = "SELECT * FROM product_images​_temporary";
sqlConnection.Execute(sqlStatement);
}
}
catch (Exception e)
{
}
Is product_images​_temporary
a reserved word in SQL Server? Like datetime
etc.? I can't explain this.
Between the s
and the _
is the Unicode zero-width-space character \u200B
. This is invisible so makes the string not what it appears to be.
This character is not legal in an SQL object identifier name and is the cause of the error you see, using []
escapes make it legal.
Simply retype the name manually or double-delete between the two characters.
As your code does work with []
it means the actual table name contains \u200B
so should also be renamed.
Just rename the table, you have an invisible character in your table's name