MS Access VBA SQL query debugging select case

前端 未结 1 1711
再見小時候
再見小時候 2021-01-29 06:41

In MS Access 2013 VBA I get a syntax error in this SQL-string:

strSQL = \"INSERT INTO [man_year] ( man_year_val, year_int, main_research_area, organisation, man         


        
相关标签:
1条回答
  • 2021-01-29 07:20

    I see at least two issues with your SQL statement:

    First, Access SQL does not support the CASE keyword. If you were thinking of the CASE ... WHEN construct in T-SQL (Microsoft SQL Server) then the equivalent in Access SQL is the Switch() function (ref: here). You can think of the Switch() function as doing

    Switch(when1, then1, when2, then2, ...)
    

    Second, as far as I know Access SQL only supports period (.) as the decimal symbol and comma (,) as the list separator, even if the Regional Settings on your machine specify other values (e.g., comma (,) as the decimal symbol and semi-colon (;) as the list separator). In other words, I'm fairly certain that

    left(KU.man_year_source;3)
    

    will never work; you'll need to use

    left(KU.man_year_source,3)
    

    instead.

    0 讨论(0)
提交回复
热议问题