我正在創建過程從一個表中複製一些列並將'狀態'列設置爲1,但它不工作可以任何一個幫助我?感謝adavance ...我想這....SQL查詢插入數據從一個表到另一個,並將目標表的'狀態'列設置爲1
ALTER PROCEDURE [dbo].[Psettemp]
AS
BEGIN
INSERT INTO tblEmailToClient
(id,
clientName,
clientInfoOrgName,
clientInfoEmail,
RemainingDays)
(SELECT a.clientinfoid AS clientId,
(client_FullName) AS client,
client_info_orgname,
client_info_email,
Datediff(day, Getdate(), WarrentyExpDate) AS RemainingDays
FROM tblSales b
JOIN tblclient_info a
ON b.client_id = a.clientinfoid
WHERE Datediff(day, Getdate(), WarrentyExpDate) = 7
OR Datediff(day, Getdate(), WarrentyExpDate) = 0)
END
請格式化您的代碼以使其易讀 – Kaf
*什麼*不起作用?你是否收到語法錯誤?那麼你會得到什麼錯誤信息?或者太多/太少的行插入?還是值不正確? –
@ThorstenKettner從第二表中的數據被插入,但我怎樣才能每一行 –