Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002

    Unanswered: How to use a variable in update statement?

    Does anyone have insight on how I can accomplish this?

    I have a table with a column called username. In that column I have a value in the form "domain_A\user". There are about 2900 records in the table. I want to change the domain portion to "domain_B"of a select few of the users based on a list. I would hope that I can use an update statement that has a variable. Then get that variable from the list I have.

    Any help is greatly appreciated.

    Online Gamers Guild

  2. #2
    Join Date
    Jul 2003
    San Antonio, TX
    update tbl set username = a.username
    from tbl inner join a_list a
    on tbl.username = replace(a.username, 'domain_B', 'domain_A')

  3. #3
    Join Date
    Sep 2003
    declare @domain varchar(20)
    set @domain = 'domain_B\'
    update test set jsp_name=@domain+substring(jsp_name,10,15) where --ur where clause

Posting Permissions

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