Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

How do I release sql express database?


Questions
I have a simple app that
uses an SQL Express 2005 database. When the user closes the app, I want
to give the option to back up the database by making a copy in another
directory. However, when I try to do it, I get "The process cannot
access the file '...\Pricing.MDF' because it is being used by another
process." I closed the connection, disposed the connection, set it to
nothing, and GC.Collect(), but it makes no difference. My connection
string is "Data
Source=.\SQLEXPRESS2005;AttachDbFilename=|DataDirectory|\Pricing.mdf;Integrated
Security=True; User Instance=True" and I just keep using the same
connection throughout. I didn't see where I could detach the database
to counter the attach in the connection string.
1 - How do I RELEASE the thing? 2 - Is there a better way than just
copying the database? The app is for my husband only, so I will be able
to handle it if he actually does need to restore from backup.
Thanks!
--------------------------------------------------------------------------------------------------
Answer
You don't want to copy the mdf directly because SQL keeps most of
the changes in the transaction log, take a look at the modified time
after running some queries, it doesn't write directly to the file. I
noticed this while setting up an rsync job.
Having SQL generate the backup is much safer and more desirable,
single-user or multi-user. You can provide a link to a function calling
the T-SQL which you can completely automate as far as source db and
destination folder:
BACKUP DATABASE [mydatabasename]
TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\Scheduled Task Backups\mydatabasename-backup' WITH NOFORMAT, NOINIT, NAME = N'mydatabasename-Full Data
SQL 2005 had introduced another T-SQL syntax to do this, for the life
of me I can't find it. But there are ways to do it through M$$SQL
without having the full blown database server.


Ïà¹ØÎĵµ£º

sql serverºÍoracleµÄÇø±ð

1£®OracleΪ¿Í»§¶Ë¿ªÆô»á»°ÓÐÁ½ÖÖ·½Ê½£º¹²Ïí·þÎñºÍרÓ÷þÎñ¡£ÔÚרÓ÷þÎñÇé¿öÏ£¬¼àÌýÆ÷ΪÁ¬½ÓÇëÇó´´½¨Ð½ø³Ì£¨Unix»·¾³ÏÂÊÇProcess£¬WindowsÏÂÎÒÏëÓ¦¸ÃÊÇThread°É£©£»¹²Ïí·þÎñÇé¿öÏ£¬¼àÌýÆ÷½«¿Í»§ÇëÇ󽻸øDispatcher£¬ÓÉDispatcher°²ÅŶà¿Í»§µÄ×÷Òµ¡£SQL ServerÔÚĬÈÏÇé¿öÏÂ×Ô¶¯Îª¿Í»§¶ËÁ¬½Ó´´½¨Ị̈߳¬µ±Óзdz£¶àµÄ¿Í ......

SQL Server 2000 ¸÷ÖÖ¶ÔÏóµÄ×î´óÖµ(ÊýÁ¿»ò´óС)

SQL Server 2000 ¸÷ÖÖ¶ÔÏóµÄ×î´óÖµ(ÊýÁ¿»ò´óС)
¹ÜÀíµÄÒ»¸öÊý¾Ý¿â´óС½«½ü10G£¬¿ªÊ¼µ£ÐÄÊý¾Ý¿â»á²»»á¹ý´ó£¬²éѯSQL ServerµÄÁª»ú´ÔÊéºó·¢ÏÖ×Ô¼ºµÄµ£ÐÄÕæµÄÊǶàÓàµÄ¡£
SQL Server 2000Êý¾Ý¿âÎļþ´óС£¨Êý¾Ý¡¢ÈÕÖ¾£©×î´ó¿ÉÒÔÖ§³Ö 32 TB µÄÎļþ
½ØÈ¡SQL Server 2000Áª»ú´ÔÊéÖеÄ×î´óÈÝÁ¿ËµÃ÷·½±ã´ó¼Ò²éÔÄ¡£
SQL ServerÊý¾Ý ......

Êý¾Ý¿â×Ö¶ÎÀàÐÍ SQL Server

—×Ö·ûÀàÐÍ
Char: ¶¨³¤·ÇUnicodeµÄ×Ö·ûÐÍÊý¾Ý£¬×î´ó³¤¶ÈΪ8000
Varchar:±ä³¤·ÇUnicodeµÄ×Ö·ûÐÍÊý¾Ý£¬×î´ó³¤¶ÈΪ8000
Text(varchar(max)):±ä³¤·ÇUnicodeµÄ×Ö·ûÐÍÊý¾Ý£¬×î´ó³¤¶ÈΪ2G
Nchar:¶¨³¤UnicodeµÄ×Ö·ûÐÍÊý¾Ý£¬×î´ó³¤¶ÈΪ8000
Nvarchar:±ä³¤UnicodeµÄ×Ö·ûÐÍÊý¾Ý£¬×î´ó³¤¶ÈΪ8000
Ntext(nvarchar(max)):± ......

SQL Server 2005Êý¾Ý¿â¾µÏñ¼ò½é

SQL Server 2005Êý¾Ý¿â¾µÏñ¼ò½é
×Ô´ÓSQL Server 2000ÒÔÀ´£¬ÄãÒѾ­Äܹ»Í¨¹ýʹÓø´ÖÆÀ´´´½¨Ò»¸ö±¸ÓõķþÎñÆ÷¡¢´«ÊäÈÕÖ¾£¬ÒÔ¼°±¸·ÝºÍÖØд洢ÁË——µ«ÊÇÏÖÔÚ΢ÈíÓÖÒýÈëÁËÒ»¸öÄÚ½¨µÄ¹¤¾ß£¬Ëü¿ÉÒÔʵÏÖ×Ô¶¯µÄ´íÎó»Ö¸´¡£Êý¾Ý¿â¾µÏñÊÇSQL Server 2005µÄÒ»¸öÐÂÌØÐÔ£¬ËüÔÊÐíÄ㽫һ¸öSQL ServerÖеÄÊý¾Ý¿âÄÚÈݾµÏñµ½ÁíÒ»¸öS ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ