Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Script not working since upgrade from 2008 to 2014

$
0
0
Hi,We have upgraded from SQL 2008 to SQL 2014, and there part of a stored procedure that isn't working, it is using an old join that isn't supported and I'm having some problems re-writing it and would love some help please.Old code that is currently working on SQL 2008 is**********************INSERT #operator_new (operatorCode, storeId, personId, storeCode, password, name, mnemonic, accessGroup, active, loggedOn, language, country, dialect, changePassword, isInShift) SELECT person.logon AS operatorCode, @storeId as storeId, person.Id as personId, busidentity.description2 as storeCode, person.password, person.familyName AS name, person.firstName AS mnemonic, person.accessGroup, 1 as active, 0 as loggedOn, -- this will be replaced with the old value person.languageCode AS language, person.countryCode AS country, NULL AS dialect, person.changePassword, isInShift = CASE WHEN timePeriod.actualEndTime IS NULL AND timePeriod.actualStartTime IS NOT NULL THEN 1 ELSE 0 END FROM person, busIdentity, accessGroup, accessGroupProperty, timePeriod WHERE person.accessGroup = accessGroup.id AND accessGroup.id = accessGroupProperty.accessGroupID AND accessGroupProperty.accessPropertyId = 1 -- access property is AccessLevel AND accessGroupProperty.content = 9 -- AccessLevel is Administrator AND Person.status = 0 -- person is active AND busIdentity.id = (Select bus.id from BusIdentity bus, Context ctx Where ctx.currentValue = bus.description2 AND ctx.subject = 'HeadOffice' AND ctx.parameter = 'Store') AND person.logon not in (select operatorCode from #Operator_new) AND timePeriod.busIdentityId = @storeId AND timePeriod.personId =* person.id AND timePeriod.actualEndTime IS NULL**********************I have tried using the following but no luck, I don't get an errors but I return no results.**********************INSERT #operator_new (operatorCode, storeId, personId, storeCode, password, name, mnemonic, accessGroup,active, loggedOn, language, country, dialect, changePassword, isInShift) SELECT p.logon AS operatorCode, @storeId as storeId, p.Id as personId, bi.description2 as storeCode, p.password, p.familyName AS name, p.firstName AS mnemonic, p.accessGroup, 1 as active, 0 as loggedOn, -- this will be replaced with the old value p.languageCode AS language, p.countryCode AS country, NULL AS dialect, p.changePassword, isInShift = CASE WHEN tp.actualEndTime IS NULL AND tp.actualStartTime IS NOT NULL THEN 1 ELSE 0 END FROM person p JOIN accessGroup ag ON p.accessGroup = ag.id JOIN accessGroupProperty agp ON ag.id = agp.accessGroupID JOIN timePeriod tp ON p.id = tp.personid JOIN BusIdentity bi ON tp.busIdentityId = bi.Id JOIN Context ctx ON ctx.currentValue = bi.description2 WHERE agp.accessPropertyId = 1 -- access property is AccessLevel AND agp.content = 9 -- AccessLevel is Administrator AND p.status = 0 -- person is active AND tp.busIdentityId = @storeId AND tp.actualEndTime IS NULL AND ctx.subject = 'HeadOffice' AND ctx.parameter = 'Store' AND NOT EXISTS (SELECT 1 FROM #Operator_new opn WHERE p.logon = opn.operatorCode)**********************Any help would be much appreciated.Kind RegardsJason

Viewing all articles
Browse latest Browse all 6525

Trending Articles