本文介绍了如何将表记录重置为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,亲爱的朋友

当我将ID列(浮点)数据类型更改为(nvarchar)时,我正在使用SQL Server 2008我丢失了正确的5000条记录,现在只有一个ID还有更多超过2或3个可用记录,所以在更改数据类型后删除主键并保存按钮会出现一条消息

(你的表格数据会丢失)

请帮帮我我可以重置我的记录



非常感谢朋友



我尝试了什么:



我尝试过最后一次备份,但只有2000条记录,但没有专业人员可以备份

Hello, dear friends
I am using SQL Server 2008 when I changed ID column (float) data type to (nvarchar) I lost the correct 5000 records, now on just one ID there is more than 2 or three records available, so after change data type and remove primary key with save button a message appeared
(Your table data will be lost)
Please help me how I can reset my records

Thanks so much friends

What I have tried:

I tried last backup but just 2000 records were there but no one a professional there to take a backup

推荐答案

-- duplicate a table's schema

SELECT TOP 0 * INTO NewTable FROM OldTable;

-- after you do that, use the table designer to alter the necessary columns' type

-- and then do a query something like this

INSERT INTO NewTable
SELECT col1,
       Convert(newtype, col2) AS col2,
       ...
FROM OldTable;





编辑=============================



雅知道当有人在没有提供理由的情况下给出答案时,它让我感到震惊。请记住,问题的质量直接影响答案的质量。



EDIT =============================

Ya know, it thrills me to no end when someone 1–votes an answer without providing a reason why. Remember, the quality of the question directly affects the quality of the answer.


引用:

我将ID列(浮点)数据类型更改为(nvarchar)我丢失了正确的5000条记录

I changed ID column (float) data type to (nvarchar) I lost the correct 5000 records



我也猜想现在,你明白为什么试验实时数据的原因是一个坏主意。



您的解决方案:采取措施防止出现这种情况。对于你的实际问题,为时已晚。

- 备份,备份备份

- 从不试验实时数据,总是制作副本,当出现问题时,它只是副本。


I also guess that now, you understand the reason why experimenting on live data is a bad idea.

Your solution: Take actions to prevent ever being in this situation. For your actual problem, it is too late.
- Backups, backups backups
- never experiment on live data, always make copies, when something go wrong, it is only a copy.


这篇关于如何将表记录重置为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 18:14
查看更多