ISSUE 1: Incorrect syntax near 'GO'.
replace GO with ;
1) GO is a keyword for Query Analyzer, not belongs to T-SQL. So, if you don't use Query Analyzer, GO is not recoganized.
2) GO instructs Query Analyzer to interpret and run the preceding T-SQL statments.
ISSUE 2: Incorrect syntax near the keyword 'DEFAULT'
You can't simply alter a column like this :
ALTER TABLE GreenscopeUser ALTER COLUMN Enabled nChar(1) not null DEFAULT 'Y';
You should alter the column like this:
ALTER TABLE GreenscopeUser ALTER COLUMN Enabled nChar(1) not null;
ALTER TABLE GreenscopeUser ADD CONSTRAINT default_Enabled DEFAULT 'Y' FOR Enabled;
Also please don't forget the remove all constraints on this column before you change it.
本文解析了两个常见的SQL语法错误:一是'GO'关键字的误用及其正确使用方式;二是如何正确地更改列属性并设置默认值。文章通过具体实例说明了如何避免这些错误。
1623

被折叠的 条评论
为什么被折叠?



