Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change col type from VFP 9
Message
 
 
To
04/09/2020 01:15:31
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01675976
Message ID:
01675996
Views:
56
I agree. My naming convention of the default constraints is similar to yours. It is DF_TABLENAME_FIELDNAME.
Thank you.

>As a side note, you should use a naming convention for naming the constraints, because sometimes you will need to modify or drop the constraints. In those cases it will be easier if you then know the names of these, rather than trying to figure them out or searching them with separate queries.
>
>In my case, I would then just calll it df_'fieldname' for instance.
>
>>I did try to put NOT NULL at the end. It made no difference.
>>
>>Antonio is right about the default constraint.
>>
>>>BTW, I think the error in the syntax is that NOT NULL part should be the last. I didn't try now, but I'm 99% certain I'm right.
>>>
>>>>>>What Antonio suggested works. Except when I use the default.
>>>>>>
>>>>>>Example:
>>>>>>
>>>>>>ALTER TABLE MyTable ALTER COLUMN notes varchar(max) not null default '' 
>>>>>>
>>>>>>
>>>>>>I am getting error "near key word Default"
>>>>>>
>>>>>>What am I missing?
>>>>>>
>>>>>>TIA
>>>>>
>>>>>Dmitry, I think this is how MSSQL adds a default value to an existing column:
>>>>>
>>>>>
>>>>>ALTER TABLE MyTable ADD CONSTRAINT DF_NotesAreEmpty DEFAULT '' FOR notes;
>>>>>
>>>>
>>>>Antonio,
>>>>I am sure your code works. But what I found is that if I change the type from Text to Varchar(max) and simply add NOT NULL, the default of the Text type stays. So, in the end I don't need to set the default.
>>>>Thank you.
>>>>
>>>>UPDATE. I believe you are right. I have to "deal" with the constraint. Because when I ALTER the column, the SQL complaints that the field NOTES depends on the constraint. So, I will have to drop the constraint first.
>>>>It is never very simple :)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform