转移SQL数据库? [英] Transfer an SQL database?

查看:81
本文介绍了转移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''
go
exit




DELETE FROM //小心!


问候,

Jeff

Q1:如何手动传输SQL数据库?

mySqlCommand4.CommandText =" EMPTY people


***通过开发人员指南发送 http:// www.developersdex.com ***

不要只参加USENET ......获得奖励!



DELETE FROM // be careful!

Regards,
Jeff
Q1: How can I transfer an SQL database manually?
mySqlCommand4.CommandText = "EMPTY people"

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


杰夫,


非常感谢你的关注...但我不认为我可以自己处理第一个问题。 ..我使用PHP大约2和一半

半年,但MSSQL给我带来了一点复杂。所以如果你有时间

我们可以通过msn在线进行吗?如果你有时间我的msn是
ce******@hotmail.com


和Q2:我知道MySQL的DELETE。我想逐一删除行

删除所有行...在MySQL EMPTY''mytable''中。是MSSQL中的DELETE

是删除所有行还是我必须逐个删除???


非常感谢你...

Cem Louis


***通过Developersdex发送 http://www.developersdex.com ***

不要只参加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.com

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 http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


你好Jeff,


无论如何我把数据库移到了链接:
http://www.support.microsoft.com/?id=224071 对我有帮助...无论如何什么

关于Q2?


谢谢...


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET .. .get奖励它!
Hi Jeff,

Anyhow I moved the database the link:
http://www.support.microsoft.com/?id=224071 was helpful... Anyway what
about the Q2?

Thank you...

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


这篇关于转移SQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆