声明:
if col_length('memes', 'rating_test') is null
begin
alter table `memes` add column `rating_test` varchar(36)
end
错误消息:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
if col_length('memes', 'rating_test') is null begin alter table `memes` add colu
' at line 1
为什么会产生上述错误消息?
最佳答案
你的语法不正确,使用这个语法它应该可以工作。
If Exists (Select 1 from INFORMATION_SCHEMA.TABLES Where Table_Name = N'YourTableName')
BEGIN
If(COL_LENGTH('[TableName]','ColumnName') is NULL)
BEGIN
Alter Table [TableName]
Add ColumnName DataType(Size) NULL
END
END
GO
关于mysql - if 和 col_length 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41529927/