Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400

    Conversione data in SQL SERVER

    Ciao, perchè questa query funziona in access e restituisce errore in sql server?:
    codice:
    function zweistellig(wert)
    if len(wert)<2 then wert = "0" & wert
    zweistellig = wert
    end function
    
    updated = right(year(date),2) & zweistellig(month(date)) & zweistellig(day(date)) & zweistellig(hour(time)) & zweistellig(minute(time)) & zweistellig(second(time))
    	sql = "insert into postings (updated)"
    	sql = sql & " values('"&updated&")"
    Errore:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e57'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Arithmetic overflow error converting expression to data type datetime.
    :master:

  2. #2
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Il problema dato da questa formattazione della data è che a volte funziona a volte no... nel db sql server il campo updated è di tipo varchar lunghezza 8000 ... è un errore occasionale ma che avviene con periodicità... altro non so dirvi...

  3. #3
    "The error typically occurs when you are trying to pass a numeric value that is too large...
    Example, trying to pass 12345.67 into a numeric(4,2) would generate the error."
    Da una ricerca con google.it

    Quindi il problema non è la data... nel tuo script cerchi di passare un valore numerico troppo grande rispetto al tipo di campo ed al suo numero massimo di caratteri previsti che hai settato nel db sql server...


  4. #4
    Utente di HTML.it L'avatar di comas17
    Registrato dal
    Apr 2002
    Messaggi
    6,522

    Re: Conversione data in SQL SERVER

    sql = sql & " values('"&updated&")"

    ... non è che ti manca un apice (') per chiudere la stringa updated ?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.