转移SQL数据库?

编程入门 行业动态 更新时间:2024-10-19 19:28:13
本文介绍了转移SQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Q1:如何手动传输SQL数据库?我有一个名为mydb的数据库 ,我查看了硬盘并发现它在 " C:\Program Files \ Microsoft Microsoft SQL Server \ MSSQL \Data"有2个文件一个 是mydb.mdf和lof文件。我在同一条路径上将这些复制在 另一台机器上但是无法使其工作??? Q2:我使用下面的代码来EMPTY一个名为people的表但 它不起作用???: SqlConnection mySqlConnection4 = new SqlConnection(" Initial 目录= mydb;数据源=" + comboBox1.SelectedItem.ToString()+ " ;;集成安全性= SSPI;"); mySqlConnection4 .Open(); SqlCommand mySqlCommand4 = mySqlConnection4.CreateCommand(); SqlTransaction myTrans; myTrans = mySqlConnection4.BeginTransaction(IsolationLevel.R eadCommitted,SampleTransaction); mySqlCommand4.Connection = mySqlConnection4; mySqlCommand4.Transaction = myTrans; mySqlCommand4.CommandText =" EMPTY人 ; //mySqlCommand4.ExecuteNonQuery(); myTrans.Commit(); mySqlConnection4.Close(); 无论如何有什么问题??? 任何帮助都将不胜感激... Cem Louis

Hi, Q1: How can I transfer an SQL database manually? I have a database which is named mydb, I looked at the harddrive and found it on "C:\Program Files\Microsoft SQL Server\MSSQL\Data" there is 2 file one of them is mydb.mdf and the lof file of that. I copied these on another machine on the same path but couldn''t make it to work??? Q2: I used the below code to EMPTY a table which is named people but it is not working???: SqlConnection mySqlConnection4 = new SqlConnection("Initial Catalog=mydb;Data Source=" + comboBox1.SelectedItem.ToString() + ";Integrated Security=SSPI;"); mySqlConnection4.Open(); SqlCommand mySqlCommand4 = mySqlConnection4.CreateCommand(); SqlTransaction myTrans; myTrans = mySqlConnection4.BeginTransaction(IsolationLevel.R eadCommitted,"SampleTransaction"); mySqlCommand4.Connection = mySqlConnection4; mySqlCommand4.Transaction = myTrans; mySqlCommand4.CommandText = "EMPTY people" ; //mySqlCommand4.ExecuteNonQuery(); myTrans.Commit(); mySqlConnection4.Close(); Anyway What is the problem??? Any help would be greatly appreciated... Cem Louis

推荐答案

Cem ... 在传输文件之前,你需要暂停数据库并分离 使用 说OSQL Cem... Before you transfer the files you need to halt the database and detach it using say OSQL sp_detach_db''mydb'',''true''一旦你转移了mdf和ldf文件就需要附加它们 使用 说OSQL start - > run OSQL / U [mypassword] / P / S [myservername] sp_attach_db''mydb'',''pathtomdf'',''pathtoldf'' go exit sp_detach_db ''mydb'',''true'' Once you have transfered the mdf and ldf files you need to attach them using say OSQL start-->run OSQL /U [mypassword] /P /S [myservername]sp_attach_db ''mydb'',''pathtomdf'',''pathtoldf''goexit

DELETE FROM //小心! 问候, Jeff Q1:如何手动传输SQL数据库? mySqlCommand4.CommandText =" EMPTY people ***通过开发人员指南发送 http:// www.developersdex *** 不要只参加USENET ......获得奖励!

DELETE FROM // be careful! Regards, Jeff Q1: How can I transfer an SQL database manually? mySqlCommand4.CommandText = "EMPTY people" *** Sent via Developersdex www.developersdex *** Don''t just participate in USENET...get rewarded for it!

杰夫, 非常感谢你的关注...但我不认为我可以自己处理第一个问题。 ..我使用PHP大约2和一半 半年,但MSSQL给我带来了一点复杂。所以如果你有时间 我们可以通过msn在线进行吗?如果你有时间我的msn是 ce******@hotmail 和Q2:我知道MySQL的DELETE。我想逐一删除行 删除所有行...在MySQL EMPTY''mytable''中。是MSSQL中的DELETE 是删除所有行还是我必须逐个删除??? 非常感谢你... Cem Louis ***通过Developersdex发送 www.developersdex *** 不要只参加USENET ......获得奖励! Hi Jeff, Thank you very much for your attention... But I don''t think I can handle the first question by myself... I am using MySQL with PHP about 2 and a half years but MSSQL comes to me a bit complicated. So If you have time can we make this online by msn? If you have time my msn is ce******@hotmail And for Q2: I know DELETE from MySQL. Deletes rows one by one I want to delete all the rows... In MySQL EMPTY ''mytable'' . Is the DELETE in MSSQL deletes all the rows or do I have to delete one by one??? Thank you indeed... Cem Louis *** Sent via Developersdex www.developersdex *** Don''t just participate in USENET...get rewarded for it!

你好Jeff, 无论如何我把数据库移到了链接: www.support.microsoft/?id=224071 对我有帮助...无论如何什么 关于Q2? 谢谢... ***通过Developersdex发送 www.developersdex *** 不要只是参加USENET .. .get奖励它! Hi Jeff, Anyhow I moved the database the link: www.support.microsoft/?id=224071 was helpful... Anyway what about the Q2? Thank you... *** Sent via Developersdex www.developersdex *** Don''t just participate in USENET...get rewarded for it!

更多推荐

转移SQL数据库?

本文发布于:2023-10-23 05:43:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519964.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!