0

I keep getting "there was an error parsing the query" no matter what I try with my DDL.

So I need an expert in the SQL-Server-CE flavor of SQL to tell me which of the following is the preferred method (or something else, quite likely). Note that I'm not worried about "SQL injection" with these string format elements:

1)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19)", tablename);
ddl = string.Format("UPDATE {0} SET redemptionID = ''", tablename);

2)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL", tablename);
ddl = string.Format("UPDATE {0} SET redemptionID = ''", tablename);
//explicitly supplying the empty string

3)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL", tablename);
//assuming the empty string is supplied automatically

4)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL WITH DEFAULT", tablename);
//assuming it automatically provides an empty string val

5)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL WITH DEFAULT ''", tablename);
//specifying the default val explicitly - an empty string

6)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL WITH DEFAULT {1}", tablename, string.empty);
//specifying the default val explicitly - an empty string via a string format element

7)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL DEFAULT ''", tablename);
//omitting the "WITH" keyword and specifying the default val explicitly - an empty string

8)

string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL DEFAULT {1}", tablename, string.empty);
//omitting the "WITH" keyword and specifying the default val explicitly - an empty string via a string format element
4

1 回答 1

2
ALTER TABLE [{0}] ADD [salvationID] nvarchar(19) NOT NULL DEFAULT ''

http://msdn.microsoft.com/en-us/library/ms174123.aspx

于 2013-03-30T01:45:32.367 回答