请让我知道此插入查询的优化提示,以便更快地执行

时间:2014-05-23 11:26:03

标签: sql

请帮我改写下面的插入查询优化。 我的stored procedure包含这些类型的插入查询,我希望通过替换

来更快地执行stored procedure
INSERT INTO [allassetsurveyreport] 
SELECT Replace(srno, 'string;#', '') AS SRNO, 
       'Yes'                         AS Responded, 
       'Yes'                         AS IsOldReport, 
       NULL                          AS [Status], 
       [pleaserateyour_x00]          AS [Overall Satisfaction], 
       [easeofuse]                   AS [Ease of Engaging], 
       responsiveness                AS Professionalism, 
       [qualityofthedeliverable]     AS [Quality of Document], 
       NULL                          AS BulkUploadReason, 
       NULL                          AS [Requested FY], 
       NULL                          AS [Requested FM], 
       NULL                          AS Vertical, 
       NULL                          AS Industry, 
       NULL                          AS PrimaryContact, 
       NULL                          AS [Topic for Proposal] 
FROM   [rfx_survey] 

1 个答案:

答案 0 :(得分:0)

我的回答仅适用于您插入此数据的表格,其中所有列的默认值均为NULL或'是'所有其他值都直接从第二个表中获取。

然后你可以使用:

INSERT INTO [allassetsurveyreport]  
     ([Overall Satisfaction], 
      [Ease of Engaging],
      Professionalism, 
      [Quality of Document])
SELECT [pleaserateyour_x00]          AS [Overall Satisfaction], 
       [easeofuse]                   AS [Ease of Engaging], 
       responsiveness                AS Professionalism, 
       [qualityofthedeliverable]     AS [Quality of Document]
FROM [rfx_survey] 

如果您按正确的顺序选择列,我不确定是否需要AS。