Search code examples
sqlsql-serversql-server-2008varbinary

Move a varbinary from one table to another with a check in SQL Server 2008


I need to copy a specific varbinary column from one table to another if it answer a simple if check.

First varbinary is from [OLDROWGAME].[dbo].[TblUnifiedItemStore1] database in a table called Store where UID=1, need to be moved to [ROWgame].[dbo].[TblUnifiedItemStore1] to a table named Store WHERE UID=1

Any way to do it?

Thanks.


Solution

  •  declare @1 table(a int , b varbinary)
     insert into @1 values(1,101010)
    
     declare @2 table(a int , b varbinary)
     insert into @2(a) values(1)
    
     update @2
     set b=(select b from @1 where a=1)
     where a=1
    
      select * from @2