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

📄 464.html

📁 关于jsp的一些好文章 主要介绍一些关于JSP的应用技巧方面的东西
💻 HTML
字号:

<STYLE type=text/css>
<!--
body,td { font-size:9pt;}
hr { color: #000000; height: 1px}
-->
</STYLE>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>FAQ汇萃 >> SQL之家 >> 用变量替代表名,列名的SQL命令怎样写?</title>
</head>
<body >

<p><IMG SRC="../image/jsp001_middle_logo.gif" WIDTH="180" HEIGHT="60" BORDER=0 ALT=""></p>

<table width=100% bgcolor="#cccccc" align=center cellpadding="2" cellspacing="0" border=1 bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#EFF8FF"><td>
<a href=http://www.jsp001.com/list_thread.php?int_attribute=1>FAQ汇萃</a>
>> <a href=http://www.jsp001.com/list_thread.php?forumid=45&int_attribute=1>SQL之家</a>
>> 用变量替代表名,列名的SQL命令怎样写? [<a href=http://www.jsp001.com/forum/showthread.php?goto=newpost&threadid=464>查看别人的评论</a>]<br>

<hr><p>由 amtd 发布于: 2001-02-15 10:00</p><p><img src="images/icons/icon1.gif" alt="Post" border=0> </p><p>用变量替代表名,列名的SQL命令怎样写?<br><br>(佚名)<br><br>答:可在帮助里查找SQL的EXEC命令信息。基本上是要运行一个已经定义好的程序。<br><br>举一个简短的例子:从一个表中选择一列<br><br>USE pubs<br><br>go<br><br><br>DECLARE @str varchar(255)<br><br>DECLARE @columnname varchar(30)<br><br><br>SELECT @columnname='au_lname'<br><br><br>SELECT @str = 'SELECT ' + @columnname + ' FROM authors'<br><br><br>EXEC (@str)<br><br>另一个例子是在线书籍中的。这个例子显示了EXECUTE命令是怎样动态处理带变量的字符串。这个例子创建一个光标(tables_cursor)来保持所有用户定义表(TYPE=‘U’)的列单。<br><br>DECLARE tables_cursor CURSOR<br><br>FOR<br><br>SELECT name FROM sysobjects WHERE type = 'U'<br><br><br>OPEN tables_cursor<br><br>DECLARE @tablename varchar(30)<br><br>FETCH NEXT FROM tables_cursor INTO @tablename<br><br>WHILE (@@fetch_status -1)<br><br>BEGIN<br><br>/*<br><br>A @@fetch_status of -2 means that the row has been deleted.<br><br>No need to test for this as the result of this loop is to<br><br>drop all user-defined tables.<br><br>*/<br><br>EXEC ("DROP TABLE " @tablename)<br><br>FETCH NEXT FROM tables_cursor INTO @tablename<br><br>END<br><br>PRINT "All user-defined tables have been dropped from the database."<br><br>DEALLOCATE tables_cursor  <br><br><br>__________________<br><font color=red>真实源于生活! </font><br>请访问我们的网站: <br>(VB爱好者乐园) <br><a href="http://www.vbgood.com" target=_blank>http://www.vbgood.com</a><br><a href="http://www.d1vb.com" target=_blank>http://www.d1vb.com</a><br><a href="http://61.128.97.225/vbgood/index.asp" target=_blank>http://61.128.97.225/vbgood/index.asp</a><br>拥有1800多个资料! </p></td>
  </tr>
</table>

<p>
<CENTER><a href="http://www.jsp001.com/forum/newreply.php?action=newreply&threadid=464">点这里对该文章发表评论</a></CENTER>
<p>该文章总得分是 <font color=red>6</font> 分,你认为它对你有帮助吗?
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=464&intVote=4","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>非常多</a>](<font color=red>1</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=464&intVote=2","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>有一些</a>](<font color=red>1</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=464&intVote=1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>无帮助</a>](<font color=red>1</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=464&intVote=-1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>是灌水</a>](<font color=red>1</font>) </p>
<script language="javascript" src="http://www.jsp001.com/include/read_thread_script.php?threadid=464"></script>
<p><CENTER>
Copyright &copy; 2001 - 2009 JSP001.com . All Rights Reserved <P>

<IMG SRC="../image/jsp001_small_logo.gif" WIDTH="85" HEIGHT="30" BORDER=0 ALT="">
</CENTER></p>

</body>
</html>

⌨️ 快捷键说明

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