|
-
Jun 22nd, 2011, 06:57 AM
#1
Thread Starter
Fanatic Member
Setting DefaultValue for Datetime
In SQL Server Express (Visual Studio 2010), I would like to set the default datetime field to the creation date & time for the record. Numerous posts indicate I should set the DefaultValue in properties to GetDate(). But this throws an error "Property Value is not valid - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.
-
Jun 22nd, 2011, 07:02 AM
#2
Re: Setting DefaultValue for Datetime
Show us the insert statement. Have you created a default for the columns? Are you just doing this in the SQL Statement?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jun 22nd, 2011, 07:06 AM
#3
Thread Starter
Fanatic Member
Re: Setting DefaultValue for Datetime
I am not doing it in code. I am just trying to set it in the Properties using the 'View Designer' (shows the relational view with the tables and fields). I select the field, which is a datetime, and try to set the DefaultValue property.
-
Jun 22nd, 2011, 07:11 AM
#4
Re: Setting DefaultValue for Datetime
I don't use the UI I do this with SQL code in SSMS like this:
sql Code:
ALTER TABLE tableNameHere
ADD CONSTRAINT [df_SomeNameHere] DEFAULT (GETUTCDATE()) FOR [ColumnNameHEre];
END
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jun 22nd, 2011, 07:14 AM
#5
Thread Starter
Fanatic Member
Re: Setting DefaultValue for Datetime
Thanks for the guidance. I know I can do it that way, but I would like to do it in the UI.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|