Wanna create a table field name as 'Name'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • prabhukumarasamy@gmail.com

    Wanna create a table field name as 'Name'

    Now i m working in a existing project. I have to do some updations. In
    that project database table contain a table(usergroup s) field name as
    'Name'. When i am trying to insert a new record in (usergoups) table
    like as follows'


    insert into UserGroups(Name ,modusr,moddt) values ('sam',131,'7/23/2006
    10:02:13 PM')


    The response ll come as follows,


    Invalid column name 'FirstName'.Inv alid column name 'LastName'.

    The usergroups table structure is as follows,


    UserGroupId int 4 (PK field)
    Name varchar 50
    modusr int 4
    moddt datetime 8


    Plz tell the correct insert query to add records for the above
    table....


    Thanks in advance

  • Ed Murphy

    #2
    Re: Wanna create a table field name as 'Name'

    On 23 Jul 2006 22:36:15 -0700, prabhukumarasam y@gmail.com wrote:
    >Now i m working in a existing project. I have to do some updations. In
    >that project database table contain a table(usergroup s) field name as
    >'Name'.
    Lex Luthor: "Are you /sure/?"
    >When i am trying to insert a new record in (usergoups) table
    >like as follows'
    >
    >
    >insert into UserGroups(Name ,modusr,moddt) values ('sam',131,'7/23/2006
    >10:02:13 PM')
    >
    >
    >The response ll come as follows,
    >
    >
    >Invalid column name 'FirstName'.Inv alid column name 'LastName'.
    >
    >The usergroups table structure is as follows,
    >
    >
    UserGroupId int 4 (PK field)
    Name varchar 50
    modusr int 4
    moddt datetime 8
    Again, are you sure?
    >Plz tell the correct insert query to add records for the above
    >table....
    If the table structure is indeed as you describe, and if UserGroupID
    is auto-assigned, then your insert should be fine.

    I suspect the table structure is not as you describe. What does
    "select * from UserGroups" give you? (Just the headers and first
    line of data would suffice.)

    Perhaps the table has "Name" *and* "FirstName" and "LastName" columns,
    with trigger logic (which may or may not be smart).

    Are you sure you're accessing the right database?

    Comment

    • Erland Sommarskog

      #3
      Re: Wanna create a table field name as 'Name'

      (prabhukumarasa my@gmail.com) writes:
      Now i m working in a existing project. I have to do some updations. In
      that project database table contain a table(usergroup s) field name as
      'Name'. When i am trying to insert a new record in (usergoups) table
      like as follows'
      >
      >
      insert into UserGroups(Name ,modusr,moddt) values ('sam',131,'7/23/2006
      10:02:13 PM')
      >
      >
      The response ll come as follows,
      >
      >
      Invalid column name 'FirstName'.Inv alid column name 'LastName'.
      >
      The usergroups table structure is as follows,
      >
      >
      UserGroupId int 4 (PK field)
      Name varchar 50
      modusr int 4
      moddt datetime 8
      >
      >
      Plz tell the correct insert query to add records for the above
      table....
      Run the query in Query Analyzer. Pay particular notice the the "Procedure"
      part of the message. I would bet that there is a trigger on the table
      that has a problem.

      --
      Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

      Books Online for SQL Server 2005 at

      Books Online for SQL Server 2000 at

      Comment

      • --CELKO--

        #4
        Re: Wanna create a table field name as 'Name'

        >project database table contain a table(usergroup s) field [sic] name as 'Name'. When I am trying to insert a new record [sic] in (usergoups) table .. <<
        >From the error message, you are not inserting into the table that you
        think you are. Those columns do not exist, based on your own personal
        pseudo-code. It will help if you post real DDL instead. Are you in
        the right database? Has the table been altered? Is there a trigger
        doing something else?

        Columns are not like fields; rows are not like records. Columns are
        referenced by name and not by position. In a file system, the program
        gives meaning to the fields in a record, so I can write code like READ
        (a,b,c) or READ(c,a,b) and load local variables. It will be garbage,
        but it will usually run. COBOL programmers had this problem all the
        time.

        You also need to learn ISO standards. Your date is not in ISO-8601
        format, and "name" (of what? Did you mean user_name? group_name?
        something else? ) violates ISO-11179 rules.

        Comment

        Working...