我要的结果是
id   col1       New_col
1   adsfsd      adsfsdasdfsdfasfdadf
2    asdfsdf    adsfsdasdfsdfasfdadf
3    asfdadf    adsfsdasdfsdfasfdadf
谢谢!

解决方案 »

  1.   

    DECLARE @strTemp VARCHAR(150)
    SET @strTemp=''
    select @strTemp=@strTemp+ dd from table2
    print @strTemp
    set @sql='select id,col1 ,New_col='''+ @strTemp + '''from table1'
    exec (@sql)
      

  2.   

    对不起,上面的错了DECLARE @strTemp VARCHAR(150)
    SET @strTemp=''
    select @strTemp=@strTemp+ col1 from table2
    set @sql='select id,col1 ,New_col='''+ @strTemp + '''from table1'
    exec (@sql)
      

  3.   

    对不起,上面又的错了DECLARE @strTemp VARCHAR(150)
    SET @strTemp=''
    select @strTemp=@strTemp+ col1 from table2
    set @strTemp='select id,col1 ,New_col='''+ @strTemp + '''from table1'
    exec (@strTemp)
      

  4.   

    DECLARE @strTemp VARCHAR(150)
    SET @strTemp=''
    SELECT @strTemp=@strTemp+col1 FROM table2
    SELECT id,col1,@strTemp as New_col
    FROM table1