如果數據是這樣的規律,可以偷下懶。
Create Table TEST
(序号 Int,
 网站 Varchar(1000))
Insert TEST Select    1,        'chinaz  chinaz  chinaz  chinaz   chinaz'
Union All Select    2,        'sohu    sohu     sohu    sohu    sohu'
Union All Select    3,        'sina     sina     sina   sina    sina'
Union All Select    4,        'tom      tom      tom    tom     tom'
Union All Select    5,        '163      163      163    163     163'
GO
Select 
序号,
Left(网站,CharIndex(' ',网站)-1) As 网站
From TEST
GO
Drop Table TEST
GO
--Result
/*
序号 网站
1 chinaz
2 sohu
3 sina
4 tom
5 163
*/

解决方案 »

  1.   

    这样不可以吗?
    update 表名 set 网站=left(网站,charindex(' ',网站))
      

  2.   

    這樣不行嗎??Update TableName Set 网站=Left(网站,CharIndex(' ',网站)-1)
      

  3.   

    各位大哥,加我QQ行么,详细说。数据有点多,不好写,批量的办法最好。我的QQ9290366
      

  4.   

    數據多怕什麼,只用這一句話,就可以,不是很複雜啊。Create Table TEST
    (序号 Int,
     网站 Varchar(1000))
    Insert TEST Select    1,        'chinaz  chinaz  chinaz  chinaz   chinaz'
    Union All Select    2,        'sohu    sohu     sohu    sohu    sohu'
    Union All Select    3,        'sina     sina     sina   sina    sina'
    Union All Select    4,        'tom      tom      tom    tom     tom'
    Union All Select    5,        '163      163      163    163     163'
    GO
    Update TEST Set 网站=Left(网站,CharIndex(' ',网站)-1)Select * From TEST
    GO
    Drop Table TEST
    GO
    --Result
    /*
    序号 网站
    1 chinaz
    2 sohu
    3 sina
    4 tom
    5 163
    */