日期:2014-05-18 浏览次数:21222 次
begin tran t1 select * into #temp from table select * from #temp commit tran t1
------解决方案--------------------
这恐怕不好实现吗?SQL语句本来就是数据库本身执行的接口
------解决方案--------------------
在c#中要用sql server临时表几乎很难,因为每次操作数据库都要重新连接数据库,然后断开,但是一旦断开临时表就没有了。
------解决方案--------------------
前台:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="True">
</asp:GridView>
<asp:Button ID="myID" runat="server" Text="Button" OnClick="myID_Click1" />
.cs文件:
protected void myID_Click1(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlConnection sc = new SqlConnection("Data Source=yourServer;Initial Catalog=yourDataBase;User ID=userid;Password=password");
SqlDataAdapter da = new SqlDataAdapter("select top 10 * into #t from [user] select * from #t", sc);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
------解决方案--------------------
你缺乏基本的SQL训练,你上面的SQL是不能执行的,下面的语句可以达到你的目的:
select a,b,c from
(select id,count(a) as a from tbA group by id) first
inner join
(select id,count(b) as b into B from tbB group by id) second on first.id=second.id
inner join
(select id,count(c) as c into B from tbC group by id) third on first.id=third.id