⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sql.htm

📁 Sql Server的例子
💻 HTM
📖 第 1 页 / 共 5 页
字号:
.menu
{
background-color: #B2C2D7;
width:90%;border: 1px; 

}
td.MenuBody
{
background-color: #F6F6F6;
}
 table.MsoNormalTable
	{mso-style-parent:"";
	font-size:10.0pt;
	font-family:"Times New Roman"
	}
</style>
</head>

<body>

<table border="0" cellpadding="10" cellspacing="0" width="100%" style="border-collapse: collapse" bordercolor="#111111">
  <tr>
    <td width="100%" bgcolor="#003366" style="border-style: solid; border-width: 1">
    <table width="96%" border="0" align="center" cellpadding="2" cellspacing="0" background="li.gif" height="34">
      <tr>
        <td align="center" height="17"><b>
        <font color="#FFFFFF">
        <a name="Microsoft SQL Server Transact-SQL   by 柯晓东"><font size="5">Microsoft 
        SQL Server Transact-SQL</font>&nbsp;&nbsp;</a></font><a name="Microsoft SQL Server Transact-SQL   by 柯晓东"><font color="#C2F3FC"> </font> </a> 
        <font color="#FFFFFF">
        <a href="mailto:kexd@neusoft.com"><font color="#C2F3FC">by 柯晓东</font></a></font><font color="#C2F3FC">&nbsp; 
        2004-9-</font></b><font color="#C2F3FC"><b>25</b></font></td>
      </tr>
      <tr>
        <td><hr color="#FFFFFF" size="1" />
        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5">
          <tr>
            <td width="100%" align="center"><a href="#创 建 账 号 和 分 配 权 限">
            <font color="#FFFFFF">创建账号和分配权限</font></a><font color="#FFFFFF">&nbsp;&nbsp;
            </font>
            <a href="#基本SQL语句"><font color="#FFFFFF">&nbsp; 基本SQL语句</font></a><font color="#FFFFFF">&nbsp;&nbsp;
            </font> <a href="#基本SQL语句"><font color="#FFFFFF">&nbsp; </font>
            </a><a href="#触发器"><font color="#FFFFFF">触发器</font></a><font color="#FFFFFF">&nbsp;&nbsp;
            </font> <a href="#基本SQL语句"><font color="#FFFFFF">&nbsp; </font> </a>
            <a href="#存 储 过 程"><font color="#FFFFFF">存储过程</font></a><font color="#FFFFFF">&nbsp;&nbsp;
            </font> <a href="#基本SQL语句"><font color="#FFFFFF">&nbsp; </font>
            </a><a href="#自 定 义 函 数"><font color="#FFFFFF">自定义函数</font></a><font color="#FFFFFF">&nbsp;&nbsp;
            </font> <a href="#基本SQL语句"><font color="#FFFFFF">&nbsp; </font>
            </a><font color="#FFFFFF"><a href="#事务"><font color="#FFFFFF">游标</font></a></font><span lang="zh-cn"><font color="#FFFFFF">&nbsp;&nbsp;&nbsp; 
            <a href="#事务"><font color="#FFFFFF">事务和锁</font></a>&nbsp; </font>&nbsp; <a href="#预 定 义 的 函 数 和 变 量">
            <font color="#FFFFFF">预定义的函数和变量</font></a></span><font color="#FFFFFF">&nbsp;&nbsp;&nbsp; 
            <a href="#重 要 的 预 定 义 的 存 储 过 程"><font color="#FFFFFF">重要的预定义的存储过程</font></a> </font>
            <a href="#基本SQL语句"><font color="#FFFFFF">&nbsp; </font> </a><span lang="zh-cn">
            <font color="#FFFFFF"><a href="#重要案例"><font color="#FFFFFF">重要案例</font>&nbsp;&nbsp;
            </a></font>&nbsp;<a target="_blank" href="http://www.microsoft.com/china/msdn/"><font color="#FFFFFF">更多</font></a></span></td>
          </tr>
        </table>
        </td>
        </tr>
      </table>
    </td>
    </tr>
    <tr>
      <td width="100%">
      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#4678A4" width="100%" id="AutoNumber1">
        <tr>
          <td width="100%" bgcolor="#003366" height="17" align="center" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
          <p align="center"><font size="3" color="#FFFFFF"><b>
          <a name="创 建 账 号 和 分 配 权 限" style="text-decoration: none">创 建 账 号 和 分 
          配 权 限</a></b></font></p>
          </td>
        </tr>
        <tr>
          <td height="1415" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="323">
            <tr>
              <td width="100%" colspan="4" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
              <font size="2">一、创建新的 Microsoft SQL Server 登录,使用户得以连接使用 SQL Server 
              身份验证的 SQL Server 实例。</font></td>
            </tr>
            <tr>
              <td width="3%" rowspan="10" height="306" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
               </td>
              <td width="97%" colspan="3" height="34" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
              语法<br />
              <b>&nbsp;&nbsp;&nbsp; sp_addlogin</b> [ @loginame = ] &#39;login&#39;&nbsp;&nbsp; 
              [ , [ @passwd = ] &#39;password&#39; ]&nbsp;&nbsp; [ , [ @defdb = ] &#39;database&#39; 
              ]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ , [ @deflanguage 
              = ] &#39;language&#39; ]&nbsp;&nbsp; [ , [ @sid = ] sid ]&nbsp;&nbsp;&nbsp; 
              [ , [ @encryptopt = ] &#39;encryption_option&#39; ]</td>
              </tr>
              <tr>
                <td width="97%" colspan="3" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                参数</td>
              </tr>
              <tr>
                <td width="3%" rowspan="6" height="221" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                 </td>
                <td width="18%" valign="top" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                [@loginame =] &#39;login&#39;</td>
                <td width="76%" valign="top" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                登录的名称。login 的数据类型为 sysname,没有默认设置。</td>
              </tr>
              <tr>
                <td width="18%" valign="top" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                [@passwd =] &#39;password&#39;</td>
                <td width="76%" valign="top" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                登录密码。password 的数据类型为 sysname,默认设置为 NULL。</td>
              </tr>
              <tr>
                <td width="18%" valign="top" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                [@defdb =] &#39;database&#39;</td>
                <td width="76%" valign="top" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                登录的默认数据库(登录后登录所连接到的数据库)。database 的数据类型为 sysname,默认设置为 master。</td>
              </tr>
              <tr>
                <td width="18%" valign="top" height="51" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                [@deflanguage =] &#39;language&#39;<br />
                 </td>
                <td width="76%" valign="top" height="51" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                用户登录到 SQL Server 时系统指派的默认语言。language 的数据类型为 sysname,默认设置为 NULL。如果没有指定 
                language,那么 language 被设置为服务器当前的默认语言(由 sp_configure 配置变量 default 
                language 定义)。更改服务器的默认语言不会更改现有登录的默认语言。language 保持与添加登录时所使用的默认语言相同。</td>
                </tr>
                <tr>
                  <td width="18%" valign="top" height="51" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                  [@sid =] sid</td>
                  <td width="76%" valign="top" height="51" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                  安全标识号 (SID)。sid 的数据类型为 varbinary(16),默认设置为 NULL。如果 sid 为 NULL,则系统为新登录生成 
                  SID。尽管使用 varbinary 数据类型,非 NULL 的值也必须正好为 16 个字节长度,且不能事先存在。SID 很有用,例如,如果要编写 
                  SQL Server 登录脚本,或要将 SQL Server 登录从一台服务器移动到另一台,并且希望登录在服务器间具有相同的 
                  SID 时。</td>
                </tr>
                <tr>
                  <td width="18%" valign="top" height="68" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                  [@encryptopt =] &#39;encryption_option&#39;</td>
                  <td width="76%" valign="top" height="68" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                  指定当密码存储在系统表中时,密码是否要加密。encryption_option 的数据类型为 varchar(20),可以是下列值之一。<br />
                  (1)NULL 加密密码。这是默认设置。 (2)skip_encryption 密码已加密。SQL Server 应该存储值而且不用重新对其加密。(3)skip_encryption_old 
                  已提供的密码由 SQL Server 较早版本加密。SQL Server 应该存储值而且不用重新对其加密。此选项只供升级使用。 
                  </td>
                  </tr>
                  <tr>
                    <td width="97%" colspan="3" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">
                    实例</td>
                  </tr>
                  <tr>
                    <td width="97%" colspan="3" height="17" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%">&nbsp;&nbsp;&nbsp; 
                    sp_addlogin &#39;用户名&#39;,&#39;密码&#39;,&#39;默认数据库名&#39;</td>
                  </tr>
              </table>
              <hr color="#003366" size="1" />
              <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="166">
                <tr>
                  <td width="100%" colspan="4" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
                  二、为 Microsoft SQL Server 登录或 Microsoft Windows NT 用户或组在当前数据库中添加一个安全帐户,并使其能够被授予在数据库中执行活动的权限。</td>
                </tr>
                <tr>
                  <td width="3%" rowspan="6" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="151">
                   </td>
                  <td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="30">
                  语法<br />
                  <b>sp_grantdbaccess</b> [@loginame =] &#39;login&#39;&nbsp; [,[@name_in_db 
                  =] &#39;name_in_db&#39; [OUTPUT]]</td>
                  </tr>
                  <tr>
                    <td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
                    参数</td>
                  </tr>
                  <tr>
                    <td width="3%" rowspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="70">
                     </td>
                    <td width="18%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
                    [@loginame =] &#39;login&#39;</td>
                    <td width="76%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
                    当前数据库中新安全帐户的登录名称。Windows NT 组和用户必须用 Windows NT 域名限定,格式为&quot;域\用户&quot;,例如 
                    LONDON\Joeb。登录不能使用数据库中已有的帐户作为别名。login 的数据类型为 sysname,没有默认值。</td>
                  </tr>
                  <tr>
                    <td width="18%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="1">
                    [@name_in_db =] &#39;name_in_db&#39; [OUTPUT]</td>
                    <td width="76%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="1">
                    数据库中帐户的名称。name_in_db 是 sysname 类型的 OUTPUT 变量,默认值为 NULL。如果没有指定,则使用 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -