Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Invalid column name error?

Invalid column name error?

Scheduled Pinned Locked Moved Database
sharepointdatabasehelpquestionannouncement
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cdietschrun
    wrote on last edited by
    #1

    Error: saving tester - TST-000-341 - item :: System.Data.SqlClient.SqlException: Invalid column name 'TST'. update tbl_swbom_checklist_testers set passfail='No' where package=992-700-358 and tester=TST-000-341 That is part of the exception thrown by my web app. There is no column named TST, the column is named TESTER, which is why the SQL statement is 'where tester=TST-000-341'. The PACKAGE column is the same syntax and it has no complaints. What am I missing here? Here is my entire SP:

    CREATE PROCEDURE dbo.sp_UpdateTesterColumn
    (
    @PACKAGE nvarchar(255),
    @TESTER nvarchar(100),
    @COLUMN nvarchar(100),
    @VALUE nvarchar(100),
    @LASTCHANGEBY nvarchar(100)
    )
    AS

    declare @sql nvarchar(1024)
    set @sql=''

    set @sql=@sql+'update tbl_swbom_checklist_testers set '+@COLUMN+'='''+@VALUE+''' '
    set @sql=@sql+'where tester='+convert(nvarchar(100),@tester)+' and package='+convert(nvarchar(255),@package)

    print @sql

    exec sp_executesql @sql
    GO

    Obviously the print is when I uncomment the print statement. What am I missing here?

    B 1 Reply Last reply
    0
    • C cdietschrun

      Error: saving tester - TST-000-341 - item :: System.Data.SqlClient.SqlException: Invalid column name 'TST'. update tbl_swbom_checklist_testers set passfail='No' where package=992-700-358 and tester=TST-000-341 That is part of the exception thrown by my web app. There is no column named TST, the column is named TESTER, which is why the SQL statement is 'where tester=TST-000-341'. The PACKAGE column is the same syntax and it has no complaints. What am I missing here? Here is my entire SP:

      CREATE PROCEDURE dbo.sp_UpdateTesterColumn
      (
      @PACKAGE nvarchar(255),
      @TESTER nvarchar(100),
      @COLUMN nvarchar(100),
      @VALUE nvarchar(100),
      @LASTCHANGEBY nvarchar(100)
      )
      AS

      declare @sql nvarchar(1024)
      set @sql=''

      set @sql=@sql+'update tbl_swbom_checklist_testers set '+@COLUMN+'='''+@VALUE+''' '
      set @sql=@sql+'where tester='+convert(nvarchar(100),@tester)+' and package='+convert(nvarchar(255),@package)

      print @sql

      exec sp_executesql @sql
      GO

      Obviously the print is when I uncomment the print statement. What am I missing here?

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Change

      cdietschrun wrote:

      package=992-700-358 and tester=TST-000-341

      with package='992-700-358' and tester='TST-000-341'


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

      C 1 Reply Last reply
      0
      • B Blue_Boy

        Change

        cdietschrun wrote:

        package=992-700-358 and tester=TST-000-341

        with package='992-700-358' and tester='TST-000-341'


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

        C Offline
        C Offline
        cdietschrun
        wrote on last edited by
        #3

        I thought so, but that code is generated by the SP, and I am having trouble with the quotation/apostrophes that properly encase each one. Could you help me and show me how to edit the SP itself?

        C 1 Reply Last reply
        0
        • C cdietschrun

          I thought so, but that code is generated by the SP, and I am having trouble with the quotation/apostrophes that properly encase each one. Could you help me and show me how to edit the SP itself?

          C Offline
          C Offline
          cdietschrun
          wrote on last edited by
          #4

          set @sql=@sql+'update tbl_swbom_checklist_testers set '+@COLUMN+'='''+@VALUE+''' '
          set @sql=@sql+'where tester='''+convert(nvarchar(100),@tester)+''' and package='''+convert(nvarchar(255),@package)
          set @sql=@sql+''''

          Ended up looking like that, if anyone was curious.

          B 1 Reply Last reply
          0
          • C cdietschrun

            set @sql=@sql+'update tbl_swbom_checklist_testers set '+@COLUMN+'='''+@VALUE+''' '
            set @sql=@sql+'where tester='''+convert(nvarchar(100),@tester)+''' and package='''+convert(nvarchar(255),@package)
            set @sql=@sql+''''

            Ended up looking like that, if anyone was curious.

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #5

            Instead using four single quotes then use CHAR(39) set @sql=@sql+'update tbl_swbom_checklist_testers set '+@COLUMN+'='+CHAR(39)+@VALUE+CHAR(39) set @sql=@sql+' where tester='+CHAR(39)+convert(nvarchar(100),@tester)+CHAR(39)+' and package='+CHAR(39)+convert(nvarchar(255),@package)+CHAR(39) Hope this helepd you.


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

            modified on Tuesday, August 4, 2009 11:56 AM

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups