Error "... is not a recognized built-in function name" in SQL Server

2

I'm not getting an insert into the SQL Server database. Here is my code:

INSERT INTO TB_Cadastro (Cod_Vac, CodIN,Produtor, Codmal, DataVac, DataCompra, NumDoc, SerieDoc, UFDoc, CodMunDoc, Lab, NumPartida, Validade, Revendedor, Doses, Qtde, Obs, tipo, Por, Qtde412Macho, Qtde1224Macho, Qtde2436Macho, Qtde36Macho, Qtde412Femea, Qtde1224Femea, Qtde2436Femea, Qtde36Femea, Campanha, CasaVet, CPFCNPJDoador, Origem, QtdeFiscalizada, TipoVacinacaoAnterior, Responsavel, NumTransfVac, ativo)
VALUES (5079,'5868','24936707287','',TO_DATE('2015-04-08 00:00:00','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2015-08-04 00:00:00','YYYY-MM-DD HH24:MI:SS'),'072608 ','','14',1400100,'20557161000198','009/2014 ',TO_DATE('','YYYY-MM-DD HH24:MI:SS'),'11','30','','','','',6,1,0,0,3,2,14,2,'2/2015','','','','','5','','','');
  

SQL Error [195] [42000]: 'TO_DATE' is not a recognized built-in function name.     java.sql.SQLException: 'TO_DATE' is not a recognized built-in function name.

    
asked by anonymous 10.08.2016 / 23:03

3 answers

1

TO_DATE is a usability function in ORACLE, the corresponding one in sql server would be the use of convert (datetime, '2015-04-08 00:00:00'), but this if your date did not have the correct form, as in the example here .

select
   convert (datetime, '20111019')
from _table

Another thing that could be using is

SET LANGUAGE { [ N ] 'language' | @language_var } 

If the date form was not in the same language as the database.

    
11.08.2016 / 03:36
1

The TO_DATE function, which you use 3 times, does not exist in SQL Server. It should be a custom function available in another DB, from where this code came originally. As taught GOKU, it is a function of Oracle.

You are already using a date format that SQL Server understands, so you can simply replace the cases like this:

  

TO_DATE ('2015-04-08 00:00:00', 'YYYY-MM-DD HH24: MI: SS')

by simply:

  

'2015-04-08 00:00:00'

    
10.08.2016 / 23:09
0

This error can also be resolved by putting the schema name of your database. example:

    
14.12.2018 / 12:57