{"id":147039,"date":"2024-11-01T12:20:12","date_gmt":"2024-11-01T04:20:12","guid":{"rendered":"https:\/\/server.hk\/cnblog\/147039\/"},"modified":"2024-11-01T12:20:13","modified_gmt":"2024-11-01T04:20:13","slug":"windows-server-2008%e4%b8%8a%e8%a8%aa%e5%95%8fsql-server%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/147039\/","title":{"rendered":"Windows Server 2008\u4e0a\u8a2a\u554fSQL Server\u7684\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"windows-server-2008%e4%b8%8a%e8%a8%aa%e5%95%8fsql-server%e7%9a%84%e6%96%b9%e6%b3%95-NECyMPlpSE\">Windows Server 2008\u4e0a\u8a2a\u554fSQL Server\u7684\u65b9\u6cd5<\/h1>\n<p>\u5728\u4f01\u696d\u74b0\u5883\u4e2d\uff0c\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u7684\u9078\u64c7\u5c0d\u65bc\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u81f3\u95dc\u91cd\u8981\u3002SQL Server\u4f5c\u70ba\u5fae\u8edf\u7684\u4e00\u6b3e\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u696d\u52d9\u5834\u666f\u4e2d\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5728Windows Server 2008\u4e0a\u8a2a\u554fSQL Server\u7684\u5e7e\u7a2e\u65b9\u6cd5\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u6709\u6548\u5730\u7ba1\u7406\u548c\u64cd\u4f5c\u6578\u64da\u3002<\/p>\n<h2 id=\"1-%e5%ae%89%e8%a3%9dsql-server-NECyMPlpSE\">1. \u5b89\u88ddSQL Server<\/h2>\n<p>\u5728\u958b\u59cb\u8a2a\u554fSQL Server\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u78ba\u4fddSQL Server\u5df2\u7d93\u5b89\u88dd\u5728Windows Server 2008\u4e0a\u3002\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u60a8\u9700\u8981\u9078\u64c7\u9069\u5408\u7684\u7248\u672c\uff08\u5982SQL Server 2008 Express\u3001Standard\u6216Enterprise\uff09\uff0c\u4e26\u6839\u64da\u9700\u6c42\u914d\u7f6e\u76f8\u61c9\u7684\u9078\u9805\u3002<\/p>\n<h3 id=\"%e5%ae%89%e8%a3%9d%e6%ad%a5%e9%a9%9f-NECyMPlpSE\">\u5b89\u88dd\u6b65\u9a5f<\/h3>\n<ul>\n<li>\u4e0b\u8f09SQL Server\u5b89\u88dd\u5305\u3002<\/li>\n<li>\u904b\u884c\u5b89\u88dd\u7a0b\u5e8f\uff0c\u9078\u64c7\u201c\u65b0\u5efaSQL Server\u7368\u7acb\u5b89\u88dd\u201d\u9078\u9805\u3002<\/li>\n<li>\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88dd\uff0c\u5305\u62ec\u9078\u64c7\u5be6\u4f8b\u540d\u7a31\u548c\u914d\u7f6e\u8eab\u4efd\u9a57\u8b49\u6a21\u5f0f\u3002<\/li>\n<li>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5SQL Server\u670d\u52d9\u3002<\/li>\n<\/ul>\n<h2 id=\"2-%e4%bd%bf%e7%94%a8sql-server-management-studio-ssms-NECyMPlpSE\">2. \u4f7f\u7528SQL Server Management Studio (SSMS)<\/h2>\n<p>SQL Server Management Studio\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u5141\u8a31\u7528\u6236\u901a\u904e\u5716\u5f62\u754c\u9762\u7ba1\u7406SQL Server\u3002\u7528\u6236\u53ef\u4ee5\u4f7f\u7528SSMS\u4f86\u5275\u5efa\u6578\u64da\u5eab\u3001\u57f7\u884c\u67e5\u8a62\u548c\u7ba1\u7406\u7528\u6236\u6b0a\u9650\u3002<\/p>\n<h3 id=\"%e9%80%a3%e6%8e%a5%e5%88%b0sql-server%e7%9a%84%e6%ad%a5%e9%a9%9f-NECyMPlpSE\">\u9023\u63a5\u5230SQL Server\u7684\u6b65\u9a5f<\/h3>\n<ol>\n<li>\u555f\u52d5SQL Server Management Studio\u3002<\/li>\n<li>\u5728\u201c\u9023\u63a5\u5230\u4f3a\u670d\u5668\u201d\u5c0d\u8a71\u6846\u4e2d\uff0c\u8f38\u5165\u4f3a\u670d\u5668\u540d\u7a31\uff08\u4f8b\u5982\uff1alocalhost\u6216\u4f3a\u670d\u5668\u7684IP\u5730\u5740\uff09\u3002<\/li>\n<li>\u9078\u64c7\u8eab\u4efd\u9a57\u8b49\u65b9\u5f0f\uff08Windows\u8eab\u4efd\u9a57\u8b49\u6216SQL Server\u8eab\u4efd\u9a57\u8b49\uff09\u3002<\/li>\n<li>\u9ede\u64ca\u201c\u9023\u63a5\u201d\u6309\u9215\u3002<\/li>\n<\/ol>\n<h2 id=\"3-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7-NECyMPlpSE\">3. \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177<\/h2>\n<p>\u9664\u4e86\u4f7f\u7528SSMS\uff0c\u9084\u53ef\u4ee5\u901a\u904e\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982sqlcmd\uff09\u4f86\u8a2a\u554fSQL Server\u3002\u9019\u5c0d\u65bc\u81ea\u52d5\u5316\u4efb\u52d9\u6216\u5728\u7121\u6cd5\u4f7f\u7528\u5716\u5f62\u754c\u9762\u7684\u60c5\u6cc1\u4e0b\u7279\u5225\u6709\u7528\u3002<\/p>\n<h3 id=\"%e4%bd%bf%e7%94%a8sqlcmd%e7%9a%84%e7%a4%ba%e4%be%8b-NECyMPlpSE\">\u4f7f\u7528sqlcmd\u7684\u793a\u4f8b<\/h3>\n<pre><code>sqlcmd -S  -U  -P <\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c\u60a8\u9700\u8981\u66ff\u63db\u3001\u548c\u70ba\u5be6\u969b\u7684\u503c\u3002\u6210\u529f\u9023\u63a5\u5f8c\uff0c\u60a8\u53ef\u4ee5\u57f7\u884cSQL\u67e5\u8a62\u3002<\/p>\n<h2 id=\"4-%e4%bd%bf%e7%94%a8ado-net%e9%80%b2%e8%a1%8c%e7%b7%a8%e7%a8%8b%e8%a8%aa%e5%95%8f-NECyMPlpSE\">4. \u4f7f\u7528ADO.NET\u9032\u884c\u7de8\u7a0b\u8a2a\u554f<\/h2>\n<p>\u5982\u679c\u60a8\u9700\u8981\u5728\u61c9\u7528\u7a0b\u5e8f\u4e2d\u8a2a\u554fSQL Server\uff0c\u53ef\u4ee5\u4f7f\u7528ADO.NET\u4f86\u5be6\u73fe\u3002ADO.NET\u63d0\u4f9b\u4e86\u4e00\u7d44\u985e\uff0c\u5141\u8a31\u958b\u767c\u8005\u8207\u6578\u64da\u5eab\u9032\u884c\u4ea4\u4e92\u3002<\/p>\n<h3 id=\"ado-net%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-NECyMPlpSE\">ADO.NET\u793a\u4f8b\u4ee3\u78bc<\/h3>\n<pre><code>\nusing System;\nusing System.Data.SqlClient;\n\nclass Program\n{\n    static void Main()\n    {\n        string connectionString = \"Server=;Database=;User Id=;Password=;\";\n        using (SqlConnection connection = new SqlConnection(connectionString))\n        {\n            connection.Open();\n            SqlCommand command = new SqlCommand(\"SELECT * FROM \", connection);\n            SqlDataReader reader = command.ExecuteReader();\n            while (reader.Read())\n            {\n                Console.WriteLine(reader[0]);\n            }\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u5728\u9019\u6bb5\u4ee3\u78bc\u4e2d\uff0c\u60a8\u9700\u8981\u66ff\u63db\u3001\u3001\u3001\u548c\u70ba\u5be6\u969b\u7684\u503c\u3002<\/p>\n<h2 id=\"5-%e7%b8%bd%e7%b5%90-NECyMPlpSE\">5. \u7e3d\u7d50<\/h2>\n<p>\u5728Windows Server 2008\u4e0a\u8a2a\u554fSQL Server\u7684\u65b9\u6cd5\u591a\u7a2e\u591a\u6a23\uff0c\u7121\u8ad6\u662f\u901a\u904e\u5716\u5f62\u754c\u9762\u7684SSMS\uff0c\u9084\u662f\u547d\u4ee4\u884c\u5de5\u5177sqlcmd\uff0c\u6216\u662f\u4f7f\u7528ADO.NET\u9032\u884c\u7de8\u7a0b\uff0c\u90fd\u80fd\u5920\u6709\u6548\u5730\u7ba1\u7406\u548c\u64cd\u4f5c\u6578\u64da\u3002\u9078\u64c7\u5408\u9069\u7684\u65b9\u6cd5\u53d6\u6c7a\u65bc\u5177\u9ad4\u7684\u9700\u6c42\u548c\u4f7f\u7528\u5834\u666f\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684<a href=\"https:\/\/server.hk\">VPS<\/a>\u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684SQL Server\uff0cServer.HK\u63d0\u4f9b\u4e86\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u7528\u6236\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u9084\u662f\u5176\u4ed6\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5728Windows Server 2008\u4e0a\u8a2a\u554fSQL Server\u7684\u6709\u6548\u65b9\u6cd5\uff0c\u63d0\u5347\u6578\u64da\u7ba1\u7406\u548c\u61c9\u7528\u6027\u80fd\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-147039","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/147039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=147039"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/147039\/revisions"}],"predecessor-version":[{"id":147045,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/147039\/revisions\/147045"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=147039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=147039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=147039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}