0

任何人都可以描述一个在存储过程中使用临时表来更新 mysql 中的两个表的简单示例吗?

4

2 回答 2

0
 --Create a temp table and insert all these counts in it
  Create Table #OperatorReportCount(Id int identity,Particulars varchar(100),NoOfArticles int)

  --Insert these values in table
  Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles processed',@ProcessedArticleCount)
  Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles approved',@ArticlesApproved)
  Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles rejected',@ArticleRejectedCount)
  Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Rejections recieved',@RejectionsRecievedCount)
  Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles put on hold',@ArticlesOnHoldCount)   

  --Select the operator count table
  Select Particulars,NoOfArticles From #OperatorReportCount
于 2012-12-26T09:07:30.827 回答
0

有两种临时表可用。一种是基于会话的,另一种是全局临时表。

下面是一个简单的例子:

    Select A,b,c into #MyTemp From MyDbTable

在上面的示例中,#myTemp 是您正在创建的临时表。MyDbTable 是您的数据库中存在的一个。您可以创建多个临时表。

我建议从这里阅读文章:链接

于 2012-12-26T06:23:33.523 回答