UPDATE – FROM … a simple solution

In order to avoid that side effect, a simple solution might be this,
create a temporary table, and use data via that table.

Here is a very simple example:

CREATE TABLE #tmp_date(datetime mydate,int idagent);

INSERT INTO #tmp_date (mydate, idagent)
SELECT GETDATE() as MyDate, ID
FROM Agents;

UPDATE Campaigns
SET Campaigns.FieldDate = A1.MyDate
FROM Campaigns AS C1 JOIN 
  #tmp_date AS A1
  ON C.IDAgent = A1.ID;

DROP TABLE #tmp_date;
About these ads

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: