You must Sign In to post a response.
  • Category: SQL Server

    Update query throw error

    I have to update the status flag as below
    Update table1 Set StatusFlag = 'C'
    where StatusFlag ='O'
    and DateFirst < '2011-12-01 00:00:00.000' and Deleted = 0

    error
    Subquery returned more than 1 value. This is not permitted when the
    subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
  • #765287
    try this code..
    Update table1 Set StatusFlag = 'C'
    where StatusFlag ='O'
    and DateFirst < CONVERT(Datetime, '2011-12-01 00:00:00', 120) and Deleted = 0

  • #765299
    Hi

    Your Query Already working for me.

    You can try this query for update



    create Table Table1
    (
    StatusFlag varchar(10),
    Datefirst datetime,
    Deleted int
    )

    SELECT * from table1
    Update table1 Set StatusFlag = 'C'
    where StatusFlag ='O'
    and DateFirst < CONVERT(Datetime, '2011-12-01 00:00:00', 101) and Deleted = 0


    select CONVERT(DATETIME,GETDATE(),101)
    select CONVERT(DATETIME,GETDATE(),102)
    select CONVERT(DATETIME,GETDATE(),103)


    --INSERT into Table1 VALUES('A',GETDATE(),0)
    --INSERT into Table1 VALUES('O',GETDATE(),0)


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments