try:
select cast((select top 1 cast(colnamel1 as bigint) from table1) & 
            (select top 1 cast(colnamel2 as bigint) from table2) as varbinary) colname3 into table3

解决方案 »

  1.   

    select * into table 3 from table1 where 1=2
    insert into table3 
    select cast((select top 1 cast(colnamel1 as bigint) from table1) & 
                (select top 1 cast(colnamel2 as bigint) from table2) as varbinary) colname3 
      

  2.   

    INSERT INTO t3 selct l1&l2 from t1 join t2 on t1.id=t2.id
      

  3.   

    INSERT INTO t3 (l3)
    (selct l1 from t1)&(select top 1 t2 from t2)INSERT INTO t3 (l3)
    (selct l1 from t1)^(select top 1 t2 from t2)INSERT INTO t3 (l3)
    (selct l1 from t1)|(select top 1 t2 from t2)
      

  4.   

    你们试过吗?我这样测得不行啊!
    另外如果l1和l2不等长,如l1为8000个字节,l2为50个字节
    循环将l2与l1^,并将所得结果累进到l3中(每次增加50个字节)如何实现???
    SQL好象无法做到吧?:(
      

  5.   

    & 在两个整型值之间执行按位逻辑与运算
    insert into t3
    select ( select cast( l1 as bigint) from t1) & (select cast(l2 as bigint) from t2)^在位运算中,只有一个 expression 可以是 binary 或 varbinary 数据类型。
    insert into t3
    select ( select l1 from t1) ^ (select cast(l2 as bigint) from t2)|insert into t3
    select ( select l1 from t1) | (select cast(l2 as bigint) from t2)
      

  6.   

    可是我的数据量很大呀,不可能每4个字节转为INT来执行操作吧,那样效率太低了:(
    我是把数据加密后存于数据库中,
    设想是在用户请求时,由存储过程读出数据并解密,将解密后的数据返回给用户
    其实问题很简单,在C中表述为
    char buf[100] , key[10] , decode[100]
    即是每次将buf中的10个字节和key执行^(异或)操作,并把结果存入decode中
    不知道在SQL中这类问题如何解决?
    另外,如果在服务器端反复执行此类操作会不会对性能影响很大?