Last post May 15, 2015 10:59 AM by missy786
May 15, 2015 10:27 AM|missy786|LINK
I am trying to run the following update query but this keeps resulting in changing the
Date fieldname to null (i.e. erases all the data from the Date fieldname.
UPDATE [dbo].[Database_CRE] SET [Date] = [newDate]
Date parameter type = nvarchar nullable
newDate parameter type = datetime nullable
Date fieldname currently contain dates in the 1-May-2015 and newDate fieldname is currently empty. I would like to copy over the column Date into newDate.
Please advice, what I may be doing wrong. Thanks
May 15, 2015 10:34 AM|gimimex|LINK
If you want to insert the value of the Date column in the column NewDate try:
UPDATE [dbo].[Database_CRE] SET [newDate] = cast([Date] as datetime)
Hope this helps.
May 15, 2015 10:35 AM|limno|LINK
You need to convert your datetime to string type to store it into that column. But it is not a good idea to store datetime in a string type anyway.
UPDATE [dbo].[Database_CRE] SET [Date] = Convert(varchar(10),[newDate],100)
May 15, 2015 10:59 AM|missy786|LINK
Thank you all for your help and time. Many thanks