{"id":181712,"date":"2020-05-18T08:16:20","date_gmt":"2020-05-18T00:16:20","guid":{"rendered":"https:\/\/gulass.cn\/?p=181712"},"modified":"2020-05-10T16:20:00","modified_gmt":"2020-05-10T08:20:00","slug":"sqlserver-connect-number","status":"publish","type":"post","link":"https:\/\/gulass.cn\/sqlserver-connect-number.html","title":{"rendered":"\u67e5\u770bSQL SERVER\u6570\u636e\u5e93\u5f53\u524d\u8fde\u63a5\u6570"},"content":{"rendered":"
1.\u901a\u8fc7\u7ba1\u7406\u5de5\u5177<\/strong><\/div>\n

\u5f00\u59cb->\u7ba1\u7406\u5de5\u5177->\u6027\u80fd\uff08\u6216\u8005\u662f\u8fd0\u884c\u91cc\u9762\u8f93\u5165 mmc\uff09\u7136\u540e\u901a\u8fc7\u6dfb\u52a0\u8ba1\u6570\u5668\u6dfb\u52a0 SQL \u7684\u5e38\u7528\u7edf\u8ba1 \u7136\u540e\u5728\u4e0b\u9762\u5217\u51fa\u7684\u9879\u76ee\u91cc\u9762\u9009\u62e9\u7528\u6237\u8fde\u63a5\u5c31\u53ef\u4ee5\u65f6\u65f6\u67e5\u8be2\u5230\u6570\u636e\u5e93\u7684\u8fde\u63a5\u6570\u4e86\u3002\u4e0d\u8fc7\u6b64\u65b9\u6cd5\u7684\u8bdd\u9700\u8981\u6709\u8bbf\u95ee\u90a3\u53f0\u8ba1\u7b97\u673a\u7684\u6743\u9650\uff0c\u5c31\u662f\u8981\u901a\u8fc7Windows\u8d26\u6237\u767b\u9646\u8fdb\u53bb\u624d\u53ef\u4ee5\u6dfb\u52a0\u6b64\u8ba1\u6570\u5668\u3002<\/p>\n

2.\u901a\u8fc7\u7cfb\u7edf\u8868\u67e5\u8be2<\/strong><\/div>\n

\u590d\u5236\u4ee3\u7801<\/p>\n

\r\nSELECT * FROM\r\n[Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT\r\n   [DBID]\r\nFROM\r\n   [Master].[dbo].[SYSDATABASES]\r\nWHERE\r\n   NAME='DBName'\r\n)\r\n<\/pre>\n

DBName\u662f\u9700\u8981\u67e5\u770b\u7684\u6570\u636e\u5e93\uff0c\u7136\u540e\u67e5\u8be2\u51fa\u6765\u7684\u884c\u6570\uff0c\u5c31\u662f\u5f53\u524d\u7684\u8fde\u63a5\u6570\u3002\u4e0d\u8fc7\u91cc\u9762\u8fd8\u6709\u4e00\u4e9b\u522b\u7684\u72b6\u6001\u53ef\u4ee5\u505a\u53c2\u8003\u7528\u3002<\/p>\n

\u4f8b\u5982\uff1a\u8fde\u5230master\u8fd9\u4e2a\u6570\u636e\u5e93\u5199\u5982\u4e0b\u8bed\u53e5:<\/p>\n

\r\nselect * from sysprocesses where dbid in (select dbid from sysdatabases where name='MyDatabase')\r\n<\/pre>\n

\u5c06\u6240\u6709\u8fde\u63a5MyDatabase\u8fd9\u4e2a\u6570\u636e\u5e93\u7684\u8fde\u63a5\u8bb0\u5f55\u90fd\u6c42\u51fa\u6765\u3002
\nsysprocesses\u8fd9\u4e2a\u8868\u8bb0\u5f55\u6240\u4ee5\u8fde\u63a5\u5230SQL SERVER\u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002<\/p>\n

3.\u901a\u8fc7\u7cfb\u7edf\u7684\u5b58\u50a8\u8fc7\u7a0b\u6765\u67e5\u627e<\/strong><\/div>\n
SP_WHO 'UserName'<\/pre>\n

UserName \u662f\u5f53\u524d\u767b\u9646Sql\u7684\u7528\u6237\u540d\uff0c\u4e00\u822c\u7a0b\u5e8f\u91cc\u9762\u90fd\u4f1a\u4f7f\u7528\u4e00\u4e2aUserName\u6765\u767b\u9646SQL\u8fd9\u6837\u901a\u8fc7\u8fd9\u4e2a\u7528\u6237\u540d\u5c31\u80fd\u67e5\u770b\u5230\u6b64\u7528\u6237\u540d\u767b\u9646\u4e4b\u540e\u5360\u7528\u7684\u8fde\u63a5\u4e86\u3002
\n\u5982\u679c\u4e0d\u5199UserName\uff0c\u90a3\u4e48\u8fd4\u56de\u7684\u5c31\u662f\u6240\u6709\u7684\u8fde\u63a5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5f00\u59cb->\u7ba1\u7406\u5de5\u5177->\u6027\u80fd\uff08\u6216\u8005\u662f\u8fd0\u884c\u91cc\u9762\u8f93\u5165 mmc\uff09\u7136\u540e\u901a\u8fc7\u6dfb\u52a0\u8ba1\u6570\u5668\u6dfb\u52a0 SQL \u7684\u5e38\u7528\u7edf\u8ba1 \u7136\u540e\u5728\u4e0b\u9762\u5217 […]<\/p>\n","protected":false},"author":1903,"featured_media":79561,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-181712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/181712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=181712"}],"version-history":[{"count":1,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/181712\/revisions"}],"predecessor-version":[{"id":181713,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/181712\/revisions\/181713"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/79561"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=181712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=181712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=181712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}