I am getting above error on below query . I am using sql 2008 SSRS
IF EXISTS
(SELECT
TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tblTemp')
DROP TABLE tblTemp
CREATE TABLE tblTemp(
EntryNo int NOT NULL
,No varchar(20) NOT NULL
,DocumentNo varchar(20) NOT NULL
);
insert into tblTemp select (Select top(1) [Entry No_] FROM [test] where [No_] = A.[No_]
and [Document no_] = A.[Document no_]) as EntryNo , A.[No_],Isnull(A.[Document no_],'') FROM [Test] as A
where A.[Date of Issue] between '2018/08/08' and '2018/08/08'
group by A.[No_],A.[Document no_]
insert into tblTemp select 999999 , A.[No_],A.[DocumentNo_] from [test2] as A
where exists (Select No from tblTemp as B where A.[No_] = B.No_)
select A.EntryNo , A.No , A.DocumentNo
from tblTemp as A order by SrfNo , EntryNo
CREATE TABLE tblTemp(
EntryNo int NOT NULL
,No_ varchar(20) NOT NULL
,DocumentNo varchar(20) NOT NULL
);
insert into tblTemp (EntryNo , No_ , DocumentNo)
select max([Entry No_]) as EntryNo
, [No_],Isnull( [Document no_],'') FROM [Test]
where [Date of Issue] between '2018/08/08' and '2018/08/08'
group by [No_], [Document no_]
insert into tblTemp (EntryNo , No_ , DocumentNo)
select 999999 , A.[No_],A.[DocumentNo_] from [test2] as A
where exists (Select No from tblTemp as B where A.[No_] = B.No_)
select EntryNo , No_ , DocumentNo
from tblTemp
order by SrfNo , EntryNo
Member
504 Points
1776 Posts
Error - Only one expression can be specified in the select list when the subquery is not introduc...
Oct 24, 2018 05:10 AM|JagjitSingh|LINK
Hi
I am getting above error on below query . I am using sql 2008 SSRS
Thanks
Contributor
6101 Points
1449 Posts
Re: Error - Only one expression can be specified in the select list when the subquery is not intr...
Oct 24, 2018 07:25 AM|eralper|LINK
I could not see an error, but had to correct typos possible related with column names.
Please execute your query step by step by commenting last commands and executing from top with adding the one more following command
SQL Server 2017
All-Star
123252 Points
10024 Posts
Moderator
Re: Error - Only one expression can be specified in the select list when the subquery is not intr...
Oct 24, 2018 01:46 PM|limno|LINK
CREATE TABLE tblTemp(
EntryNo int NOT NULL
,No_ varchar(20) NOT NULL
,DocumentNo varchar(20) NOT NULL
);
insert into tblTemp (EntryNo , No_ , DocumentNo)
select max([Entry No_]) as EntryNo
, [No_],Isnull( [Document no_],'') FROM [Test]
where [Date of Issue] between '2018/08/08' and '2018/08/08'
group by [No_], [Document no_]
insert into tblTemp (EntryNo , No_ , DocumentNo)
select 999999 , A.[No_],A.[DocumentNo_] from [test2] as A
where exists (Select No from tblTemp as B where A.[No_] = B.No_)
select EntryNo , No_ , DocumentNo
from tblTemp
order by SrfNo , EntryNo
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm