SQL server 2008R2中怎么直接修改表内数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL server 2008R2中怎么直接修改表内数据相关的知识,希望对你有一定的参考价值。

1、首先打开数据库查询语句,输入查询语句先查询一下数据表中的数据内容。

2、输入查询语句,:Select * from Student,输入完毕之后选择全部内容,选择执行按钮,执行SQL语句。

3、执行完毕之后,在Student表中的第四行数据(StudentName中的“崔”),这里需要把它修改为“亮亮”。

4、在你的数据表上,用鼠标右击选择里面的“编辑前200行”。

5、编辑完毕之后,可以在查询表中看到你的所有数据,如下图中红线内容。

6、这里直接选择里面的内容把它修改成“亮亮”。

7、修改完毕之后这里选择右击内容,选择里面的执行。

8、执行完毕之后,同样的方式,用数据查询语句查询数据,这里可以在如下图中看到已经成功的修改了数据内容。

参考技术A 在SQL Server Management Studio的对象管理器中,找到你要输入数据的表,按鼠标右键,选择“编辑TOP 200行(Edit Top 200 Rows)”,在右边的表格中可以直接编辑。
但如果需要编辑更多数据,例如1000行,此时可点击工具栏中sql调出sql窗口,其中显示select top 200....,可将200改为1000. 以此类推。本回答被提问者采纳
参考技术B 你用sqlserver management连上服务器,然后就可以改啦

???Sql Server???SQL SERVER ????????????

?????????int   with   ??????   serve   span   ??????   inner   --   blog   

??????:???Sql Server???SQL SERVER ????????????

??????SQL SERVER 2005?????????????????????????????????????????????SQL SERVER 2005???????????????CTE?????????????????????CTE?????????????????????

??????CTE??????????????????Common Table Expression ???SQL SERVER 2005????????????????????????????????????

#??????????????????

1???sql

 1 Create table GroupInfo([Id] int,[GroupName] nvarchar(50),[ParentGroupId] int)
 2 
 3 Insert GroupInfo
 4 
 5 select 0,??????????????????,null union all
 6 
 7 select 1,??????????????????,0 union all
 8 select 2,??????????????????,1 union all
 9 select 3,??????????????????,1 union all
10 select 4,????????????????????????,2 union all
11 select 5,????????????????????????,2 union all
12 select 6,????????????????????????,3 union all
13 select 7,????????????????????????,3 union all
14 
15 select 8, ???????????????,0 union all
16 select 9, ?????????????????????,8 union all
17 select 10,????????????????????????,8 union all
18 select 11,???????????????????????????,9 union all
19 select 12,???????????????????????????,9 union all
20 select 13,??????????????????????????????,10 union all
21 select 14,??????????????????????????????,10 

2????????????

 ????????????

#????????????Demo

1???????????????????????????????????????????????????,???????????????????????????

 1 --????????????????????????????????????????????????
 2 with
 3 CTE
 4 as
 5 (
 6     select * from GroupInfo where Id=1
 7     union all
 8     select G.* from CTE inner join GroupInfo as G
 9     on CTE.Id=G.ParentGroupId
10 )
11 select * from CTE order by Id

 

 1 --????????????????????????????????????????????????
 2 with
 3 CTE
 4 as
 5 (
 6     select * from GroupInfo where Id=14
 7     union all
 8     select G.* from CTE inner join GroupInfo as G
 9     on CTE.ParentGroupId=G.Id
10 )
11 select * from CTE order by Id

2?????????????????????

 1 --??????????????????
 2 with
 3 CTE
 4 as
 5 (
 6     select Id,GroupName,ParentGroupId,GroupPath=CAST( GroupName as nvarchar(max)) from GroupInfo where Id=1
 7     union all
 8     select G.*,CAST(CTE.GroupPath+???//???+G.GroupName as nvarchar(max)) as GroupPath from CTE 
 9     inner join GroupInfo as G
10     on CTE.Id=G.ParentGroupId
11 )
12 select * from CTE

????????????

 3?????????????????????????????????????????????????????????

 1 --??????id????????????????????????????????????sort??????????????????sort??????????????????????????????????????????????????????
 2 WITH    
 3 CTE
 4 AS 
 5 ( 
 6     SELECT * ,CAST(RIGHT(???000??? + CAST([Id] AS VARCHAR), 3) AS VARCHAR(MAX)) AS sort FROM GroupInfo
 7     WHERE ParentGroupId = 0
 8     UNION ALL
 9     SELECT   GroupInfo.* ,CAST(sort + RIGHT(???000??? + CAST(GroupInfo.[Id] AS VARCHAR),3) AS VARCHAR(MAX)) AS sort
10     FROM CTE
11     INNER JOIN GroupInfo ON CTE.Id = GroupInfo.ParentGroupId
12 )
13 SELECT * FROM CTE ORDER BY sort 

 ????????????

4?????????????????????????????????????????????????????????

1 --??????????????????
2 WITH CTE AS (
3     SELECT *,1 AS [Level] FROM GroupInfo WHERE ParentGroupId=0
4     UNION ALL
5     SELECT G.*,CTE.Level+1 FROM GroupInfo as G 
6     JOIN CTE ON CTE.Id =G.ParentGroupId
7 )
8 SELECT * FROM CTE

 ????????????

 

以上是关于SQL server 2008R2中怎么直接修改表内数据的主要内容,如果未能解决你的问题,请参考以下文章

sql server 2008r2 向带有索引的表里大批量插入数据

查看SQL SERVER 2008R2 表大小

sql server 2008r2默认实例名登录(服务器)时应该怎么写?

SQL SERVER 2008R2 错误码查询地址

SQL Server 2008r2 检查语法的下划线没有显示出来怎么办

根据 SQL Server 2008R2 中表中的列获取计数