Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    9

    Red face Unanswered: Variable Column names

    I am writing a stored procedure in which I have a query that selects the Headings of Columns from another table...
    I want to then create a loop that will contain a variable with the value of the column heading and then set the column to a value of NULL...

    Is there any way to accomplish this???

    I thought about placing these values into a temp table...

    This is what I have so far...

    Declare @QueryX nvarchar(500)
    Declare @FieldName varchar(20)

    Create Table #UpdateRejDoc
    (
    Abbreviation varchar(20)
    )
    Insert into #UpdateRejDoc
    Select Abbreviation
    From tbl_Titles
    left JOIN tbl_TitleRouting on tbl_Titles.Title_ID = tbl_TitleRouting.Title_ID
    Where tbl_TitleRouting.Application_ID = @Application_ID
    While Exists (Select Abbreviation from #UpdateRejDoc)
    Begin

    Set @QueryX = 'Update DBLandfillUser.tbl_ObjectApprovals' +
    '@AppName + Set @FieldName = null Where object_id =' + Cast(@object_id as VarChar(20))
    End

  2. #2
    Join Date
    Mar 2004
    Posts
    9
    Could I incorporate exec sp_columns TableName into my code to get the desired results?? If so, how?

    (I am really new to this!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •