I have a several strings, which i want to append to use it as a statement:
string tableToSelect = "COUNT(Table) as Table";
StringBuilder sqlQuery = new StringBuilder();
sqlQuery.Append("SELECT Month,");
sqlQuery.Append(tableToSelect);
sqlQuery.Append(" from ");
sqlQuery.Append("tbl_TEST");
If I copy-paste the result into SQL Server Management Studio it gives me following:
SELECT Month, COUNT(Table)-as-Table from tbl_TEST
Any ideas?
That should be fine; thoughts:
.NET will not invent dashes.
and from where exactly are you copying? (since you haven’t even called
sqlQuery.ToString()yet).