I am totally stuggeling with the the conversion from nvarchar datatype to decimal and date.
I extracted data from SAP with SE16 imported the flat file to SQL server. All fields have the datatype nvarchar(50). I now need to change the datatype for the date fields (AUDAT) to a date and NETWR to numeric. Here an extract:
MANDT AUDAT NETWR 010 02.10.2007 44,657.60 010 02.08.2008 58.76 010 02.11.2007 11,752.00 010 05.10.2007 0.00 010 02.10.2007 748.16
For AUDAT I used the following code which seams to work, however changes the date format to yyyy-mm-dd instad of dd.mm.yyyy:
UPDATE VBAK SET [AUDAT ] = CONVERT(date, [AUDAT ],104)
The conversion from NETWR to a decimal datatype doesn't work at all. I always get a "Error converting data type nvarchar to numeric" error:
UPDATE VBAK SET [NETWR ] = CONVERT(DECIMAL(10,2),REPLACE(REPLACE([NETWR ], ',', ''), ',', ','))I try here also to get rid of the ,-thousand separator.