DECLARE @ImportDate as DateTime
SELECT @ImportDate = '2010-01-13 09:45:00'
INSERT dbo.Customers ([Name], ListSegmentsID, ListDOMsCompanyNumbersID,
ListVerticalsID, ListAreasID, ListRegionsID,
UpdatedByUserID,DateUpdated,ListCountryTypesID, AffinityID)
select distinct s$.CustomerName as CustomerName,
ls.id as segmentID, doms.ID as DomsID,
lv.ID as VerticalID, la.ID as AreaID, lr.ID as RegionID,
323 as ToolsTeamID, @ImportDate as UpdatedByDate, CT.ID as Country, s$.AffinityNumber
from _ImportCustomers5 s$
left join ListSegments ls on ls.Segment = s$.Segment
left join ListDOMsCompanyNumbers doms on doms.DOMsCompanyNumber = s$.DOMSCompanyNum
left join ListVerticals lv on lv.Vertical = s$.Vertical
left join ListAreas la on la.Area = s$.Area
left join ListRegions lr on lr.Region = s$.Region
left join ListCountryTypes as CT On CT.CountryType = s$.Country
where NOT EXISTS (Select * from dbo.Customers c where c.name = s$.CustomerName)
order by s$.CustomerName
commit
rollback
update _ImportIssues5
set QuestCustomerID = c.ID
FROM _ImportIssues5 i$
INNER JOIN dbo.Customers c on c.Name = RTrim(i$.CustomerName)
ROLLBACK
COMMIT
Always do Commit or Rollback ... (I said or !!!)
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
This code is medium "off-topic" as it is done in SQL * Server. But as Commit and Rollback is a universal medium, he deserves a prominent place as well:
Yes, I was in production
-
- Moderador
- Posts: 1177
- Joined: Thu, 15 Oct 2009 10:28 am
- Location: Recife
This last update must be very important, uahuiahuaa
always from rollback
always from rollback
-
- Rank: Programador Sênior
- Posts: 58
- Joined: Fri, 30 Oct 2009 9:52 am
- Location: Salvador - BA
- Contact:
Atenciosamente,
João Paulo A. C. do Bomfim
"Deu certo? Deixa! Funcionou? Não mexa!"
João Paulo A. C. do Bomfim
"Deu certo? Deixa! Funcionou? Não mexa!"
Curious ...
The table that is suffering update, in the case
is being monitored by some trigger with an associated procedure?
take it away, maybe it's a silada..rs
interesting the post.
The table that is suffering update, in the case
_ImportIssues5
,is being monitored by some trigger with an associated procedure?
take it away, maybe it's a silada..rs
interesting the post.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest