@@ -180,7 +180,7 @@ private static Column GetPrimaryKeyColumn(List<Column> columns)
180
180
public static string CreateTableQuery ( string tableName , List < Column > columns )
181
181
{
182
182
string query =
183
- "CREATE TABLE " + SanitizeString ( tableName ) +
183
+ "CREATE TABLE [ " + SanitizeString ( tableName ) + "] " +
184
184
"(" ;
185
185
186
186
int added = 0 ;
@@ -220,7 +220,7 @@ public static string CreateTableQuery(string tableName, List<Column> columns)
220
220
221
221
public static string DropTableQuery ( string tableName )
222
222
{
223
- string query = "IF OBJECT_ID('dbo." + SanitizeString ( tableName ) + "', 'U') IS NOT NULL DROP TABLE dbo. " + SanitizeString ( tableName ) ;
223
+ string query = "IF OBJECT_ID('dbo." + SanitizeString ( tableName ) + "', 'U') IS NOT NULL DROP TABLE [ " + SanitizeString ( tableName ) + "]" ;
224
224
return query ;
225
225
}
226
226
@@ -265,7 +265,7 @@ public static string SelectQuery(string tableName, int? indexStart, int? maxResu
265
265
//
266
266
// table
267
267
//
268
- query += "FROM " + SanitizeString ( tableName ) + " " ;
268
+ query += "FROM [ " + SanitizeString ( tableName ) + "] " ;
269
269
270
270
//
271
271
// expressions
@@ -303,7 +303,7 @@ public static string SelectQuery(string tableName, int? indexStart, int? maxResu
303
303
public static string InsertQuery ( string tableName , string keys , string values )
304
304
{
305
305
string ret =
306
- "INSERT INTO " + tableName + " WITH (ROWLOCK) " +
306
+ "INSERT INTO [ " + tableName + "] WITH (ROWLOCK) " +
307
307
"(" + keys + ") " +
308
308
"OUTPUT INSERTED.* " +
309
309
"VALUES " +
@@ -315,7 +315,7 @@ public static string InsertQuery(string tableName, string keys, string values)
315
315
public static string UpdateQuery ( string tableName , string keyValueClause , Expression filter )
316
316
{
317
317
string ret =
318
- "UPDATE " + tableName + " WITH (ROWLOCK) SET " +
318
+ "UPDATE [ " + tableName + "] WITH (ROWLOCK) SET " +
319
319
keyValueClause + " " +
320
320
"OUTPUT INSERTED.* " ;
321
321
@@ -327,7 +327,7 @@ public static string UpdateQuery(string tableName, string keyValueClause, Expres
327
327
public static string DeleteQuery ( string tableName , Expression filter )
328
328
{
329
329
string ret =
330
- "DELETE FROM " + tableName + " WITH (ROWLOCK) " ;
330
+ "DELETE FROM [ " + tableName + "] WITH (ROWLOCK) " ;
331
331
332
332
if ( filter != null ) ret += "WHERE " + filter . ToWhereClause ( DbTypes . MsSql ) + " " ;
333
333
0 commit comments