怎样修改SQL Server 2000数据表?
本人是非常笨的人,能找到SQLServer2000数据表,能打开但是不会修改,修改或者增加了又不知道怎么储存,有那位大侠能帮帮忙。谢谢!或者给找一个可以直接进入数据库哪里...
本人是非常笨的人,能找到SQL Server 2000数据表,能打开但是不会修改,修改或者增加了又不知道怎么储存,有那位大侠能帮帮忙。谢谢!或者给找一个可以直接进入数据库哪里修改的软件。非常感激。
展开
5个回答
展开全部
1、在企业管理器里,在右边的树展开,找到你的库,展开,单击表,在左边的屏幕上就有库中所有的表,选择你要修改的表,右键,选择打开表/查询,在出现的SQL语句中补充完整条件,执行该语句,找到你要修改的记录,在下面结果窗口修改,修改完鼠标点击一下窗口其它地方,关闭即保存
2、在SQL查询分析器里写UPDATE set脚本语句来修改
2、在SQL查询分析器里写UPDATE set脚本语句来修改
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可通过一下的存储过程来实现的。以下代码在SQL Server 2000 + SP4中调试通过。
if exists(select * from sysobjects where lower(name)=lower('up_AddCol4Obbr') and xtype='P')
drop procedure up_AddCol4Obbr
go
create procedure up_AddCol4Obbr
@strTable nvarchar(100),
@strColName nvarchar(100),
@strType nvarchar(100)
as
begin
declare @strSQL nvarchar(1000)
if not exists(select * from syscolumns where lower(name)=lower(@strColName) and id in (select id from sysobjects where lower(name)=lower(@strTable) ))
begin
select @strSQL = N'alter table ' + @strTable + ' add ' + @strColName + ' ' + @strType
exec sp_executesql @strSQL
end
else
begin
select @strSQL = N'alter table ' + @strTable + ' alter column ' + @strColName + ' ' + @strType
exec sp_executesql @strSQL
end
end
go
if exists(select * from sysobjects where lower(name)=lower('up_CheckCols4Obbr') and xtype='P')
drop procedure up_CheckCols4Obbr
go
create procedure up_CheckCols4Obbr
as
begin
declare @nColCnts smallint, @nShopCnts smallint, @nCol smallint, @nShop smallint
declare @strColName nvarchar(30), @strType nvarchar(50), @strTable nvarchar(50)
select @nColCnts = count(*) from u_obbc
select @nShopCnts = count(*) from u_obbs
select @nCol=1, @nShop=1, @strTable='U_OBBR'
while @nCol<=@nColCnts
begin
select @strColName = 'TC' + right('00'+cast(@nCol as nvarchar(10)),2)
select @strType = dType from joyouext.dbo.u_obbc where colId = @nCol
exec up_AddCol4Obbr @strTable, @strColName, @strType
select @nCol = @nCol + 1
end
while @nShop<=@nShopCnts
begin
set @nCol=1
while @nCol<=@nColCnts
begin
select @strColName = 'BC' + right('00'+cast(@nShop as nvarchar(10)),2) + right('00'+cast(@nCol as nvarchar(10)),2)
select @strType = dType from joyouext.dbo.u_obbc where colId = @nCol
exec up_AddCol4Obbr @strTable, @strColName, @strType
select @nCol = @nCol + 1
end
select @nShop = @nShop + 1
end
end
go
if exists(select * from sysobjects where lower(name)=lower('up_AddCol4Obbr') and xtype='P')
drop procedure up_AddCol4Obbr
go
create procedure up_AddCol4Obbr
@strTable nvarchar(100),
@strColName nvarchar(100),
@strType nvarchar(100)
as
begin
declare @strSQL nvarchar(1000)
if not exists(select * from syscolumns where lower(name)=lower(@strColName) and id in (select id from sysobjects where lower(name)=lower(@strTable) ))
begin
select @strSQL = N'alter table ' + @strTable + ' add ' + @strColName + ' ' + @strType
exec sp_executesql @strSQL
end
else
begin
select @strSQL = N'alter table ' + @strTable + ' alter column ' + @strColName + ' ' + @strType
exec sp_executesql @strSQL
end
end
go
if exists(select * from sysobjects where lower(name)=lower('up_CheckCols4Obbr') and xtype='P')
drop procedure up_CheckCols4Obbr
go
create procedure up_CheckCols4Obbr
as
begin
declare @nColCnts smallint, @nShopCnts smallint, @nCol smallint, @nShop smallint
declare @strColName nvarchar(30), @strType nvarchar(50), @strTable nvarchar(50)
select @nColCnts = count(*) from u_obbc
select @nShopCnts = count(*) from u_obbs
select @nCol=1, @nShop=1, @strTable='U_OBBR'
while @nCol<=@nColCnts
begin
select @strColName = 'TC' + right('00'+cast(@nCol as nvarchar(10)),2)
select @strType = dType from joyouext.dbo.u_obbc where colId = @nCol
exec up_AddCol4Obbr @strTable, @strColName, @strType
select @nCol = @nCol + 1
end
while @nShop<=@nShopCnts
begin
set @nCol=1
while @nCol<=@nColCnts
begin
select @strColName = 'BC' + right('00'+cast(@nShop as nvarchar(10)),2) + right('00'+cast(@nCol as nvarchar(10)),2)
select @strType = dType from joyouext.dbo.u_obbc where colId = @nCol
exec up_AddCol4Obbr @strTable, @strColName, @strType
select @nCol = @nCol + 1
end
select @nShop = @nShop + 1
end
end
go
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
打开查询分析器,SQL的命令语句都在那里输入的
创建名字为student的表格,括号内为其列名:
create table student(Sno char(10),Sname char(2),Ssex char (2),Sage char (2),Sdept char(2))
在student表格中插入数据:
INSERT INTO Student(Sno,Sname,Ssex,Sage,Sdept) VALUES('200215121','李勇','男' ,19,'CS');
删除学号为200215121的学生记录:
delete from student where sno=200215121
修改表格名字:
sp_rename 'student','stu'
.....等等........还有很多很多~~~~自己在以后进一步学习中漫漫体会吧!
创建名字为student的表格,括号内为其列名:
create table student(Sno char(10),Sname char(2),Ssex char (2),Sage char (2),Sdept char(2))
在student表格中插入数据:
INSERT INTO Student(Sno,Sname,Ssex,Sage,Sdept) VALUES('200215121','李勇','男' ,19,'CS');
删除学号为200215121的学生记录:
delete from student where sno=200215121
修改表格名字:
sp_rename 'student','stu'
.....等等........还有很多很多~~~~自己在以后进一步学习中漫漫体会吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
安装了SQL Server 2000 就可以使用界面化操作了。
很简单的。
很简单的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |