开发者

CREATE DATABASE fails using VSDBCMD

When trying to deploy a VS2010 database project using the VSDBCMD tool, I get the following error:

SQL01268 .Net SqlClient Data Provider: Msg 5133, Level 16, State 1, Line 1 Directory lookup for the file "D:\MSSQL10_50\MSSQL10_50.MSSQLSERVER\MSSQL\Data\Data.mdf" failed with the operating system error 21(failed开发者_开发问答 to retrieve text for this error. Reason: 1815).
SQL01268 .Net SqlClient Data Provider: Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

However, if I take the SQL script generated by VSDBCMD and run it in SQL Management Studio, it works fine. Similarly, I can create the DB manually in Mgt Studio.

'Operating system error 21' is apparently Device Not Ready, but this looks spurious to me... The folder paths are all correct, and unlocking the security on the folders doesn't fix the issue (e.g. 'everyone' > full control). Also, there are no errors in the SQL log or event viewer on the server.

What is different between running VSDBCMD on the command line, and running the same SQL script through Management Studio??

Any ideas very welcome!

Chris


As per my own comments, this error was because the drive didn't actually exist.


If you are creating database with vsdbcmd in a server based on a dbschema, it would be nice to set path location for data and log files.

To change log path location in your .dbschema file:

<Element Type="ISql90File" Name="[YOUR_DATABASE_NAME_Data]">
    <Property Name="FileName" Value="E:\YOUR DATA FOLDER\$(DatabaseName)_Data.MDF" />

<Element Type="ISql90File" Name="[YOUR_DATABASE_NAME_Log]">
    <Property Name="FileName" Value="E:\YOUR LOGS FOLDER\$(DatabaseName)_Log.LDF" />

then import it into Sql Server using Command prompt:

CD\
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Deploy\vsdbcmd.exe" /a:Deploy 
/cs:"Server=YOUR_SERVER\YOUR_INSTANCE;User Id=YOUR_USER;Password=YOUR_PASS;Pooling=false" 
/dsp:Sql /dd+ /model:"C:\FOLDER\YOUR_DBSCHEMA_FILE.dbschema" 
/p:TargetDatabase="YOUR_DATABASE_NAME"

More info on vsdbcmd: http://msdn.microsoft.com/en-us/library/dd193283.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜