SQL Server CE's DDL parser is very picky but secretive about what it is finding fault with

谁都会走 提交于 2019-12-11 18:54:52

问题


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

回答1:


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

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



来源:https://stackoverflow.com/questions/15713194/sql-server-ces-ddl-parser-is-very-picky-but-secretive-about-what-it-is-finding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!