Forum Discussion
SQL Sever Query With Temp tables will not import - Errors dont align
- 6 years ago
Hi Anonymous ,
I test this in my environment with below code, which work well
Create table #tt1 ( name varchar(20), id int) insert into #tt1 values('a', 1), ('b',2) Create table #tt2 (name varchar(20), id int) insert into #tt2 values('a1', 1), ('b1',3) select a.name, a.id,b.name from #tt1 a left join #tt2 b on a.id=b.idSo I think two temp tables should work. You could try to test below to see whether it work or not. Or you also could use create a stored procedure, then use it in powerbi to see whether it work or not.
CREATE TABLE #ISM(
Users INT,
Proj_Number VARCHAR(100),
Proj_Name VARCHAR(100))
INSERT INTO #ISM
SELECT
COUNT(U.[personid]) AS Users
,P.Proj_Number,
P.Proj_name
FROM [A].[USERS] AS U
JOIN A.Projects AS P
ON P.project_seq_id = U.project_seq_id--WHERE P.proj_number LIKE '150666'
GROUP BY
P.Proj_Number,
P.Proj_nameselect * from #ISM
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
I test this in my environment with below code, which work well
Create table #tt1 (
name varchar(20), id int)
insert into #tt1 values('a', 1), ('b',2)
Create table #tt2 (name varchar(20), id int)
insert into #tt2 values('a1', 1), ('b1',3)
select a.name, a.id,b.name from #tt1 a left join #tt2 b on a.id=b.id
So I think two temp tables should work. You could try to test below to see whether it work or not. Or you also could use create a stored procedure, then use it in powerbi to see whether it work or not.
CREATE TABLE #ISM(
Users INT,
Proj_Number VARCHAR(100),
Proj_Name VARCHAR(100))
INSERT INTO #ISM
SELECT
COUNT(U.[personid]) AS Users
,P.Proj_Number,
P.Proj_name
FROM [A].[USERS] AS U
JOIN A.Projects AS P
ON P.project_seq_id = U.project_seq_id
--WHERE P.proj_number LIKE '150666'
GROUP BY
P.Proj_Number,
P.Proj_name
select * from #ISM
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.