.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Sub-query returns more than 1 value, but there is no sub-query

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :Sql Server

I have the update statement below which gives me the an error that the sub-query returns more than 1 value. There is no sub-query. Thanks for any help you can provide.

begin tran

update FileLoadRequest set StatusID = 1



Msg 512, Level 16, State 1, Procedure Trg_RequestModified, Line 10

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

The statement has been

View Complete Post

More Related Resource Links

Any way to execute a workflow when a caml query returns zero items?

Lets say I have a list with a status column and I want to execute a workflow when all items in the list have a status of complete. I basically want to execute a workflow when the caml query looking for non-complete statuses returns zero rows. Can I do this with SPD or are there any 3rd party tools for this? I'm thinking of writing one if there are not.

Analysis Services - Query returns a #error result

Hi, I have a cube - which i had backed up and just retored it. After the restoration, when i try to reply the cube e.g: select [Time].&[200503] on 0 , {[Process].[All process]} on 1 from [myConsolidations] - i recieve an a result showing #error only. What could be the cause of this?

show a "no results" message if a db query returns nothing

I inherited some C# code behind that queries a database table and need to add something that displays a "No results" message (using a Label web control, perhaps) if the query doesn't return any records. I'm just learning C# but am coming up short on how to do this. Would anyone be kind enough to point me to an example, or demonstrate? Thanks a lot. Here's the code I inherited (the programmer who wrote this is no longer available). This is the code behind from the search results page:using System; using System.Text; using System.Data; using System.Data.Common; using System.Data.SqlClient; using System.Collections; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Maine_Innkeeper_Site_2010 { public partial class lodging_search_output : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string sql = Session["logdingSearchSql"].ToString(); SqlCommand cmd = common.openDatabase(); cmd.CommandText = sql; string PreviousTown = ""; try { StringBuilder sb = new StringBuilder(); SqlDataReader rdr = cmd.ExecuteReader(); sb.Append("<ul class=lodging-search-initial-results>"); while (rdr.Read()) {

How do I create a query that joins two tables and returns a single entry with the most recent update


Say I have the following two tables (Purchase & Customer). 

CustomerID StoreName PurchaseDate
1 Asheville 9/14/2010 15:49

Query returns correct rows but I am not able to concatenate the rows into a variable :(


Hi all,

Why in the code below I am able to list all rows and display the field 'stepID' but I am not able to concatenate them all in the variable @stepIds?

declare @date as datetime
set @date = '2010-09-20 23:01:20:000'
declare @instance as uniqueidentifier
set @instance = '04658F34-CBF1-4CCD-A683-F23BDB669D35'

  Declare @CrLf char(2)
  Set @CrLf = Char(13) + Char(10)
	Declare @stepIds varchar(8000)
	Set @stepIds = ''
		--@stepIds = @stepIds + ' - Step: ' + CONVERT(varchar(4), stepID)

Display a message if query returns no data


I added a text box to my report reading: "No Data Matches Search Criteria".  I tried to add a visibility expression: =iif((Rownumber("SalesCube")=0),1,0)

I get "The Hidden expression usied...returned a data type that is not valid"

What am I doing wrong???


query wich returns records for each day between start date from table 1 and mutation dates in table



I have to tables with dates, table Employments with all employements of all employees, with start date and end date, and a table Mutations with mutations (e.g in salary) with start dates.

Now I try to write a query which returns a record for each day an employee is in employment, with the correct salary. SO at first, it should return all days between the employment start date and the first mutation date, then the number of days between the first mutation date and the second mutation date etcetc, and at last the number of days between the last mutation date and the employment end date. The number of mutations varies for each employment, and employees cna have multiple employments (history, so not at the same time) in the employments table.

How to do this?

Select second query if first query returns nothing



How can I SELECT second if first SELECT returns nothing?


Select second query if first query returns no rows



I need to return result of the second select statement if the first select statement returns nothing:

-- First statement
SELECT Salesmen.SalesmanID, Salesmen.FullName, 
  Salesmen.AssignedAppointments, Salesmen.Picture, 
FROM Appointments INNER JOIN
  Salesmen ON 
  Appointments.SalesmanID = Salesmen.SalesmanID
WHERE (Appointments.Closed = 1)
ORDER BY Salesmen.AssignedAppointments
-- Second statement
FROM Salesmen
ORDER BY AssignedAppointments

BOTH (1) AND (2) Query Returns same result


  select * from tblEmp
  select @@ROWCOUNT

 select * from tblEmp
 select @@ROWCOUNT

BOTH (1) AND (2) Query Returns same result
1. Employee details
2. No of row effected
and which is faster count(*) or global @@ROWCOUNT

This query does not work, it returns more than 5 Categories

The following query, is supposed to return only the 'top 5' categories of sales, based on sales amt. However, it is returning much more than 5. Perhaps someone can see what the problem is?

/****** Object: StoredProcedure [dbo].[_USP_QuoteMonth_Top5_only5] Script Date: 11/03/2010 17:12:08 ******/
/* --------------------------------------------------------------------------------------------------------*/
ALTER PROCEDURE [dbo].[_USP_QuoteMonth_Top5]
@FromDate VARCHAR(25),
@ToDate VARCHAR(25),
@CUSTNAME varchar(250),
@Department varchar(4000),
@Category varchar(4000),
@SalesTypes Varchar(50),
@Debug bit = 0
EXEC [_USP_QuoteMonth_Top5_only5] '01/01/2009', '01/31/2009', 'Northern Manor Multicare center', 'ALL' , 'ALL', '1'
EXEC [_USP_QuoteMonth_Top5_only5] '01/04/2009', '01/08/2009', 'Northern Manor Multicare center', 'ALL' , 'ALL', '1', @Debug = 1

EXEC [_USP_QuoteMonth_Top5_only5] '01/01/2009', '12/31/2009', 'Northern Manor Multicare center', 'ALL' , 'ALL', '1'
EXEC [_USP_QuoteMonth_Top5_only5] '01/01/2009', '12/31/2009', 'Northern Ma

Passing parameter to Subreport dataset query returns no results



I'm using the subreport as a workaround to not being able to join two disparate datasets. The "tickler" file  of keys comes from an Access DB defined as a dataset in my main report. The subreport has a dataset query using parameters from the main report. 

When subreport returns no results, I want to display an error message in the main report and continue to the next row key processing. How do I accomplish that?


CAML query on Lookup field returns no items



I have a problem with a very simple CAML query that works on WSS 3, but not on SharePoint 2010. The query is:

<Where><Eq><FieldRef Name='CUSTTABLE' LookupId='TRUE' /><Value Type='Lookup'>5624</Value></Eq></Where>

Where CUSTTABLE is the lookup field and 5624 is the ID of the item that the lookup value points to.

This works fine on WSS 3 but on 2010 it returns no results, I expect 5 results as I manually created 5 items that points to the item in the other list.

I'm not getting any errors, and queries on other non-lookup fields work as expected.

I have also tried changing the Type='Lookup' to Type='Integer' as someone suggested that might be the problem.

Has something changed in 2010? What is my next steps to figuring this out....



Query a Table with Japanese Characters returns always 0 results


Hi all, I wonder if you could give me a hand on this please...

I've a table (lets say with 2 columns: ID int, Vendor Name nvarchar(255)) with some records with Japanese Characters. 

When I try to query that table for the specific rows with Japanese string I always get 0 results.


Table example:


ID Vendor Name

1 Bruno Ferreira

2 ??????????


Query Example:

select * from myTbl where [Vendor Name] collate <<collations name>> = '??????????'


Result always nothing...


I've tried with all the possible available collations but with no luck

collations I've tried:











SQL 2008 to iSeries via linked server (IBMDASQL) - TOP 10 * SQL query returns ALL records


I am querying a iSeries - AS400 database from SQL server 2008 server 64 bit,  via a linked server (using OLE DB Provider - IBMDASQL)

The SQL is select top 10 * FROM <linked Svr>.<Dest server>.<DBName>.<TableName>

Instead of returning top 10 rows, the query returns ALL the rows. I use the top 10 sql query in my "Heart beat monitor" to check the viability of the linked server after a server reboot.  If the test query work

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend