I have always worked wth Sqlbase, but I have a project in SqlServer (Of which I know very little), but when I try to do an insert/ update with a datetime field I get the following error:
[Microsoft][SQL Server Native Client 11.0]Invalid character value for cast specification...
I have the following Insert Statement:
INSERT INTO dbo.colaboradores (Anio,Pais,ID_Usuario,Apellido,Nombre,Level,fecha_Ingreso ) Values (:nAno,:sPais,:sDatos[0],:sDatos[1],:sDatos[2],:sDatos[3],:dtFecIng)
the value of dtFecIng (as Seen in the debugger) is: 2003-03-07-01.01.01.000000
Can anybody guide me on what I am doing wrong?
Thanks in advance
Inserting a date into SqlServer 2012
Re: Inserting a date into SqlServer 2012
You should not get that error, but sqlbase has a DATE data type which sqlserver does not. When comparisons take place, the time can cause all sorts of problems and you will not get the equality. Advisable to make the time part always zero.
Set dtCurrent = SalDateConstruct( SalDateYear( dtCurrent ), SalDateMonth( dtCurrent ), SalDateDay( dtCurrent ), 0, 0, 0 )
Set dtCurrent = SalDateConstruct( SalDateYear( dtCurrent ), SalDateMonth( dtCurrent ), SalDateDay( dtCurrent ), 0, 0, 0 )
Re: Inserting a date into SqlServer 2012
Try to change the ODBC Driver from SQL Server Native Client 11.0 to SQL Server
We always use this one since many years with different kind of TD versions
And I remember error messages, if we used one of the native clients.
regards
M.Schmidt
We always use this one since many years with different kind of TD versions
And I remember error messages, if we used one of the native clients.
regards
M.Schmidt
Re: Inserting a date into SqlServer 2012
After changing to SQL Server driver, set the dateformat through SET DATEFORMAT if you still face problem.
Regards
Siva A
Regards
Siva A
Re: Inserting a date into SqlServer 2012
Thanks to all I will give it a try.!!
Who is online
Users browsing this forum: No registered users and 0 guests