无论我如何尝试DDL,我总是收到“解析查询时出错”的消息。
因此,我需要一位SQL-Server-CE风格的SQL专家来告诉我以下哪种方法是首选方法(或者很可能是其他方法)。请注意,我并不担心使用这些字符串格式元素进行"SQL注入“:
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 string3)
string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL", tablename);
//assuming the empty string is supplied automatically4)
string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL WITH DEFAULT", tablename);
//assuming it automatically provides an empty string val5)
string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19) NOT NULL WITH DEFAULT ''", tablename);
//specifying the default val explicitly - an empty string6)
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 element7)
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 string8)
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发布于 2013-03-30 09:45:32
ALTER TABLE [{0}] ADD [salvationID] nvarchar(19) NOT NULL DEFAULT ''http://msdn.microsoft.com/en-us/library/ms174123.aspx
https://stackoverflow.com/questions/15713194
复制相似问题