SQL Server CE的DDL解析器非常挑剔,但对于发现问题的原因却是秘密的 [英] SQL Server CE's DDL parser is very picky but secretive about what it is finding fault with

查看:289
本文介绍了SQL Server CE的DDL解析器非常挑剔,但对于发现问题的原因却是秘密的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我使用DDL尝试什么,我都会不断收到解析查询时出错的信息。

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

所以我需要SQL Server-方面的专家CE风格的SQL告诉我以下哪种方法是首选方法(或者,很可能还有其他方法)。请注意,我不担心这些字符串格式元素的 SQL注入:

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


推荐答案

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

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

这篇关于SQL Server CE的DDL解析器非常挑剔,但对于发现问题的原因却是秘密的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆