logo
down
shadow

SQL server 2008 - subquery returned more than one value


SQL server 2008 - subquery returned more than one value

By : Sophie Fisher
Date : November 22 2020, 10:31 AM
hope this fix your issue You cannot use a CASE statement against a result set - it must be run against a single value.
I believe this is what you are trying to accomplish, which is an evaluation on each MAILING_DOCUMENT field in the CHDOCS table:
code :
SELECT CHDOCS.MAILING_ID

    -- Check if the Mailing Document field matches the pattern *EX*
    ,CASE WHEN CHDOCS.MAILING_DOCUMENT LIKE N'%EX%' 
        THEN CHDOCS.MAILING_DOCUMENT  -- It does, return the field value.
        ELSE ''                       -- It doesn't, return empty.
        END AS DOC

FROM CHDOCS


Share : facebook icon twitter icon
SQL Server Subquery returned more than 1 value. This is not permitted when the subquery follows (chars) or when the subq

SQL Server Subquery returned more than 1 value. This is not permitted when the subquery follows (chars) or when the subq


By : txy1330
Date : March 29 2020, 07:55 AM
this will help I am trying to update some fields based on their occurence. If they only occur one time, I am updating some status field. , Use IN keyword instead of equals operator like so:
code :
UPDATE table1
SET statusField = 1
WHERE someID IN (
           SELECT someID
           FROM table1
           GROUP BY someID HAVING COUNT(*) = 1
           )
SQL Server 2008 :: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <

SQL Server 2008 :: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <


By : Jeroen
Date : March 29 2020, 07:55 AM
I hope this helps you . Be aware that an UPDATE or a DELETE can affect more than one record and your trigger will have to deal with them at once, in this case your "inserted" or "deleted" table will have more than one record.
You will have to use a join in your DML. Something like this:
code :
UPDATE [dbo].[UserInformationComputed]
                SET
                CompanyID = inserted.CompanyID,
                law_id = inserted.ID,
                Status = inserted.Status,
                FirstName = inserted.FirstName,
                LastName = inserted.LastName
            from inserted
    WHERE  
                UserInformationComputed.law_id = inserted.ID
DELETE FROM [dbo].[UserInformationComputed]
    WHERE law_id in (SELECT id FROM deleted)
Subquery returned more than 1 value in SQL SErver 2008

Subquery returned more than 1 value in SQL SErver 2008


By : damian
Date : March 29 2020, 07:55 AM
To fix this issue Please see my previous question that I am still stuck with. Insert statement with sub queries , This statement is causing the problem:
code :
SET @ItemId = (select itemid from janel.dbo.item
WHERE janel.dbo.item.itemnumber like 'c-%' and listprice > 0 );
SET @ItemId = (select TOP 1 itemid from janel.dbo.item
WHERE janel.dbo.item.itemnumber like 'c-%' and listprice > 0 );
i am executing this query in sql server 2008 r2 the result is " Subquery returned more than 1 value. This is not pe

i am executing this query in sql server 2008 r2 the result is " Subquery returned more than 1 value. This is not pe


By : Sjoerd
Date : March 29 2020, 07:55 AM
Hope that helps , I think you just want something like this:
code :
 select purchase_id ,
        COALESCE(v.vessel_name,j.jetty_name) as vessl_name
 from dbo.tbl_Purchase p
         left join
      dbo.tbl_Vessel v
         on
            p.source_type in (1,2) and
            v.vessel_type = p.source_type
         left join
      dbo.tbl_Jetty j
         on
            p.source_type not in (1,2)
(select source_type from dbo.tbl_Purchase where purchase_id  = tbl_Purchase.purchase_id)
(select source_type from dbo.tbl_Purchase p2 where p2.purchase_id  = p1.purchase_id)
SQL Server 2008 (SP4) Subquery returned more than 1 value

SQL Server 2008 (SP4) Subquery returned more than 1 value


By : gazum
Date : March 29 2020, 07:55 AM
hope this fix your issue
SELECT @IGI = (SELECT a.IGXF FROM DBO.Details a, DELETED i WHERE a.IGXF = i.IGXF)
code :
SET NOCOUNT ON;
DELETE FROM dbo.SUPPORT
WHERE IGBA IN(
    SELECT a.IGXF
    FROM dbo..Details AS a
    JOIN DELETED  AS i ON
        a.IGXF = i.IGXF
    );
Related Posts Related Posts :
  • error even after following Microsoft format in SQL
  • Increase price by percentage, results rounded
  • Can we Use "Case" in a ColdFusion Query-of-Query
  • displaying 'Active' for a row which has 'A' as value
  • Using pattern search in SQL Server Query
  • SQL - how to group transactions for a certain date pattern?
  • How to Index SQL with multiple AND conditions nested inside OR
  • SQL rank with priority
  • Does BigQuery support SubQueries?
  • Any ideas for persisting H2 Database In-Memory mode transaction?
  • How to improve SQL query performance (correlated subqueries)?
  • Filter repeated columns in Oracle
  • SQL Server join on whichever column has value populated
  • use sql stored procedure to insert data which is returned from a query stored in a table
  • Query not working1
  • SQL - using an alias in a where clause in a subquery
  • How to search for a whole word with special char using oracle contains?
  • Production Perfomance of using SELECT * statements?
  • String concatenation not working as expected in SELECT statement
  • How to detect which stored procedures UPDATE or INSERT into a certain TABLE?
  • Select statement inside CASE - SQL
  • .Net Float error 4 - float(4) = 4.44089209850063E-16
  • How to show as column to recursive rows in a table With SQL Server
  • SQL Server error: Column name or number of supplied values does not match table definition
  • How to find a table name which's column name consist cl_
  • Cannot access existing table from WCF Code
  • SQL CREATE VIEW Error
  • Many Statement in the same transaction PLSQL
  • Tables are not joining properly in sql server 2008
  • DB2 how to sum two column from two different table
  • SQL msAccess: list unfinished courses of a student
  • SQL Server delete multiple rows
  • Finding max(date) from the resultant query output
  • updating multiple columns using case statement in sql server
  • Nested SQL query having select subquery in update statement
  • "putting" a certain object to the screen from inside an array
  • Retrieve segment from value
  • Error while creating a table in oracle 11g
  • Transaction with Sequelize doesn't work
  • Search time complexity of this sql query
  • How to return unique records between two tables without using distinct and union?
  • Is it possible to maximum occurences of a value for each key in my table all in one query?
  • Divide table into groups of 5000 based on rank
  • rolling back exec and sp_OA methods
  • How to convert multiple rows to one row in SQL Server?
  • How to use substring and charindex in google query language
  • Find table information where part of column matches char variable
  • Need to retrieve rows from table where the following condition was not satisfied column A = column B and column B = colu
  • Assigning an index to a constraint
  • Retrieve records from multiple Records returned by Sub-Query
  • SQL DELETE group of records based on opposite group being empty
  • SQL GetDate() returns wrong time
  • Total sales amount for customers in cities
  • SQL Server -- updating the `sys.*` tables and not just reading them
  • SQL Order By using concat
  • Group Data Hourly and Insert Into a Summary Table in Postgres
  • Execute SQL Server Pass-Through Query From Access VBA
  • MS Access SQL Transform Aggregate Manipluation of Values for Pivot
  • SQL "if exists..." dynamic query
  • HANA: Split string?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org