Sql Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sujitbhattacharya
    New Member
    • Feb 2008
    • 3

    Sql Error

    Dear Community

    I have posted my question earlier also regarding INSERT QUERY

    My question is like
    I have two tables in a database One is Employee master (that is Employee) and other is Salary Master (that is Sal_mast)
    What I want that the data in employee_Id which is a field in the Table (Employee) should get copied in the Employee_Code Field of the Table (Sal_Mast).

    Initially I used the Data Enviornment for Creating an SQL STATEMENT thru SQL Builder.


    The Code What i wrote was like

    INSERT INTO 'SAL_MAST' (Employee_Code)
    SELECT Employee_ID FROM Employee WHERE (Employee_Id = 'S0010')

    Now in the SQL Build it is working Fine , when I'm using the same coding in the VB6 Code Window it is not physically updating the Table.

    Pls Let me know where is the fault and how to come out of this . Since this is my first Project I have very Short Time left for submission

    Regards

    Sujit
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Originally posted by sujitbhattachar ya
    Dear Community

    I have posted my question earlier also regarding INSERT QUERY

    My question is like
    I have two tables in a database One is Employee master (that is Employee) and other is Salary Master (that is Sal_mast)
    What I want that the data in employee_Id which is a field in the Table (Employee) should get copied in the Employee_Code Field of the Table (Sal_Mast).

    Initially I used the Data Enviornment for Creating an SQL STATEMENT thru SQL Builder.


    The Code What i wrote was like

    INSERT INTO 'SAL_MAST' (Employee_Code)
    SELECT Employee_ID FROM Employee WHERE (Employee_Id = 'S0010')

    Now in the SQL Build it is working Fine , when I'm using the same coding in the VB6 Code Window it is not physically updating the Table.

    Pls Let me know where is the fault and how to come out of this . Since this is my first Project I have very Short Time left for submission

    Regards

    Sujit
    The single quotes around your tablename are a bit strange to me.

    Also, If you look again at your SQL logic, it is asking the SELECT statement to get something it already knows: an employee_id of S0010

    In other words, doing the following will accomplish the same thing AND be alot faster:

    Code:
    INSERT INTO SAL_MAST (Employee_Code) VALUES ('S0010')
    If Employee_ID is not really what you needed, then your SELECT is fine and is just a syntax thing but the table being wrapped in quotes may correct your issue. Brackets should be used instead: [tablename] and not 'tablename'

    Comment

    Working...