Forum Discussion
Error in Sql Server base
Good morning/evening/night people!
I created a relatory in Power BI using temporary tables in SQL Server query, and in the first moment, everything work normaly.
2 Replies
- vanessafvgCommunity Champion
can you share your sql code? dont think this is a problem of no lock
- grupoipemigNew Member
I tried again and work normaly, can be any local problem in Power BI? Because I tried in saved archive and in new archive and I had the error.
I can't share the SQL code, but I maked other equal that I used before.
The SQL code is like this:
SELECT A.Date AS MonthYear,
CASE WHEN SUBSTRING(A.Date, 0, 3) = '01' THEN '01 - Janeiro'
WHEN SUBSTRING(A.Date, 0, 3) = '02' THEN '02 - Fevereiro'
WHEN SUBSTRING(A.Date, 0, 3) = '03' THEN '03 - Março'
WHEN SUBSTRING(A.Date, 0, 3) = '04' THEN '04 - Abril'
WHEN SUBSTRING(A.Date, 0, 3) = '05' THEN '05 - Maio'
WHEN SUBSTRING(A.Date, 0, 3) = '06' THEN '06 - Junho'
WHEN SUBSTRING(A.Date, 0, 3) = '07' THEN '07 - Julho'
WHEN SUBSTRING(A.Date, 0, 3) = '08' THEN '08 - Agosto'
WHEN SUBSTRING(A.Date, 0, 3) = '09' THEN '09 - Setembro'
WHEN SUBSTRING(A.Date, 0, 3) = '10' THEN '10 - Outubro'
WHEN SUBSTRING(A.Date, 0, 3) = '11' THEN '11 - Novembro'
ELSE '12 - Dezembro' END AS Periodo,
B.NameFun AS Consultor,
C.NameSup AS Supervisor,
A.Meta AS MetaMes
INTO #METAS
FROM MetasFuncionarios A
LEFT JOIN Funcionarios B ON (A.FuncionarioCod = B.FuncionarioCod)
LEFT JOIN Equipes C WITH(NOLOCK) ON (B.EquipeCod = C.EquipeCod)
WHERE B.FuncionarioStatus = 'A'
AND A.Observacoes = 'Comissao'
SELECT * FROM #METAS
DROP TABLE #METASPS: I think I found the error but I'm not sure, maybe the problem is selecting DirectQuery. When I select Import and place the SQL query it works normally.