2011-12-03 19 views
7

के माध्यम से SQL सर्वर डेटाबेस प्रोजेक्ट (SSDT) ​​परिनियोजित करें मेरे पास SQL ​​Server 2012 RC0 डेटाबेस को लक्षित करने वाला SQL सर्वर डेटाबेस प्रोजेक्ट है। परियोजना विजुअल स्टूडियो 2010 + एसक्यूएल सर्वर डेटा टूल्स सीटीपी 4 में बनाई गई थी। प्रोजेक्ट प्रकार नियमित विजुअल स्टूडियो 2010 डेटाबेस प्रोजेक्ट से अलग है (यह SQL डेवलपर टूल्स सीटीपी 3 जूनू का अगला संस्करण है)।कमांड लाइन

यह आईडीई में जुर्माना लगाता है। मैं कमांड लाइन के माध्यम से इसे कैसे तैनात कर सकता हूं?

मैंने वीएसडीबीसीएमडी.एक्सई की कोशिश की लेकिन यह एक .deploymanifest फ़ाइल की अपेक्षा करता है जो नए प्रोजेक्ट प्रकार द्वारा नहीं बनाया गया है।

उत्तर

24

उपयोग sqlpackage.exe, C:\Program Files\Microsoft SQL Server\{version}\DAC\bin या C:\Program Files (x86)\Microsoft SQL Server\{version}\DAC\bin जहां {version} = 110 (SQL सर्वर 2012), 120 (SQL सर्वर 2014), आदि

कमांड लाइन तर्क में स्थित:

/Action:{Extract|Report|Publish|Script} Specifies the action to be performed. 
             (short form /a) 

/Quiet[+|-]        Specifies whether detailed feedback is 
             suppressed. Defaults to False. (short 
             form /q) 

/OverwriteFiles[+|-]      Specifies if sqlpackage.exe should 
             overwrite existing files. Specifying 
             false causes sqlpackage.exe to abort 
             action if an existing file is 
             encountered. Default value is True. 
             (short form /of) 

/SourceServerName:<string>    Defines the name of the server hosting 
             the source database. (short form /ssn) 

/SourceDatabaseName:<string>    Defines the name of the source 
             database. (short form /sdn) 

/SourceUser:<string>      For SQL Server auth scenarios, defines 
             the SQL Server user to use to access 
             the source database. (short form /su) 

/SourcePassword:<string>     For SQL Server auth scenarios, defines 
             the password to use to access the 
             source database. (short form /sp) 

/SourceTimeout:<int>      Specifies the timeout for establishing 
             a connection to the source database in 
             seconds. (short form /st) 

/SourceEncryptConnection[+|-]   Specifies if SQL encryption should be 
             used for the source database 
             connection. (short form /sec) 

/SourceTrustServerCertificate[+|-]  Specifies whether to use SSL to 
             encrypt the source database connection 
             and bypass walking the certificate 
             chain to validate trust. (short form 
             /stsc) 

/SourceConnectionString:<string>   Specifies a valid SQL Server/Azure 
             connection string to the source 
             database. If this parameter is 
             specified it shall be used exclusively 
             of all other source parameters. (short 
             form /scs) 

/SourceFile:<string>      Specifies a source file to be used as 
             the source of action instead of a 
             database. If this parameter is used, 
             no other source parameter shall be 
             valid. (short form /sf) 

/TargetServerName:<string>    Defines the name of the server hosting 
             the target database. (short form /tsn) 

/TargetDatabaseName:<string>    Specifies an override for the name of 
             the database that is the target of 
             sqlpackage.exe Action. (short form 
             /tdn) 

/TargetUser:<string>      For SQL Server auth scenarios, defines 
             the SQL Server user to use to access 
             the target database. (short form /tu) 

/TargetPassword:<string>     For SQL Server auth scenarios, defines 
             the password to use to access the 
             target database. (short form /tp) 

/TargetTimeout:<int>      Specifies the timeout for establishing 
             a connection to the target database in 
             seconds. (short form /tt) 

/TargetEncryptConnection[+|-]   Specifies if SQL encryption should be 
             used for the target database 
             connection. (short form /tec) 

/TargetTrustServerCertificate[+|-]  Specifies whether to use SSL to 
             encrypt the target database connection 
             and bypass walking the certificate 
             chain to validate trust. (short form 
             /ttsc) 

/TargetConnectionString:<string>   Specifies a valid SQL Server/Azure 
             connection string to the target 
             database. If this parameter is 
             specified it shall be used exclusively 
             of all other target parameters. (short 
             form /tcs) 

/TargetFile:<string>      Specifies a target file (i.e., a 
             .dacpac files) to be used as the 
             target of action instead of a 
             database. If this parameter is used, 
             no other target parameter shall be 
             valid. This parameter shall be invalid 
             for actions that only support database 
             targets. (short form /tf) 

/Properties:<string>      A name value pair for a Publish 
             property, {PropertyName}={Value}. 
             Refer to the help for the Publish 
             action for valid property names. 
             (short form /p) 

/Variables:<string>      Optional only if /Action:Publish is 
             specified. Valid values for parameter 
             name shall be SQL Command variables 
             specified in the .dacpac file only. 
             Parameter names specified that are not 
             declared in the .dacpac shall result 
             in an error. Valid command variable 
             values shall be context-specific based 
             on the command variable itself (e.g., 
             database name vs. schema names). 
             (short form /v) 

/Profile:<string>      Optional if /Action:Publish is 
             specified. Valid value is a file path 
             to a Publish Profile. A user shall be 
             able to use a Publish Profile to 
             define the collection of Publish 
             Properties to use for a Publish 
             episode. (short form /pr) 

/OutputPath:<string>      Required if /Action:Report or 
             /Action:Script is specified. Valid 
             value is a file path to where the 
             comparison report shall be written. 
             (short form /op) 

@<file>         Read response file for more options. 

उदाहरण:
sqlpackage.exe /Action:Publish /SourceFile:C:\DbProject\bin\Debug\DbProject.dacpac /TargetServerName:localhost /TargetDatabaseName:TestDb

टी के साथ एक प्रोफ़ाइल में संग्रहीत db विवरण arget:
sqlpackage.exe /Action:Publish /SourceFile:C:\DbProject\bin\Debug\DbProject.dacpac /Profile:C:\DbProject\LocalDb.publish.xml

आप त्रुटि मिलती है तो सुनिश्चित करें कि आप sqlpackage.exe का सही संस्करण (अधिक जानकारी के लिए here देखें) का उपयोग कर रहे हैं "में असमर्थ सर्वर को लक्षित करने के लिए कनेक्ट करने के लिए"।

+1

[ऑनलाइन दस्तावेज़ों से] (http://msdn.microsoft.com/en-us/library/hh550080%28VS.103%29.aspx) –

+0

विजुअल स्टूडियो 2013 में एसएसडीटी के लिए भी काम करता है। – Keith

+0

क्या/targetConnectionString ओवरराइड/प्रोफ़ाइल दोनों निर्दिष्ट हैं? @ किथ – Json

2

यदि आप एक मासोचिस्ट माइक्रोसॉफ्ट हैं तो 'PowerShell का उपयोग करके' documentation on deploying the DACPAC via SMO प्रदान करते हैं।

बेशक

आप भी PowerShell से sqlpackage कॉल कर सकते हैं ...

+0

ग्रेट लिंक्ड आलेख। लेकिन संभावित लिंक-रोट को रोकने के लिए लेख से प्रासंगिक अंशों के साथ अपने उत्तर का विस्तार करने के लिए समय निकालें! धन्यवाद। – bPratik