Column Name Not Recognised Even Though The Procedure Returns A Table With That Name??

Apr 27, 2006

I am databinding a dataset formed from a stored procedure,(all done on page_load).

However, the reference to the column name is not recognised with the following error being returned.
Column with name "CalcVal" was not found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Column with name "CalcVal" was not found.

Source Error:





Line 152: chartCommand.Fill(chartDs);
Line 153: Chart1.DataSource = chartDs;
Line 154: Chart1.DataBind();
Line 155:
Line 156: }

This worked before deployment and the other controls which are bound to data using stored procedures seem to work. However, these other data sources are all sqlDatasoure controls.

Any suggestions would be helpful.

I have found issues relating the to user ID and password which seems to depend on whether the web server and data server are the same machine or whether they are remote from each other.

cheers-jim.

View 1 Replies


ADVERTISEMENT

Stored Procedure That Returns The Next Value In Sequence For A Column

Mar 9, 2008

I have a Column called SaleID in some tables in a Database.The SaleID column has the int datatype. I need a stored procedure that returns the next value in sequence for the SaleID column.

For Example,
If the last value inserted into the SaleID column was 1022 the stored procedure should return 1023
If the last value inserted into the SaleID column was 1023 the stored procedure should return 1024.
If the last value inserted into the SaleID column was 1024 the stored procedure should return 1025.

Also an exclusive lock should be maintained while the the stored procedure is running.

I am using SQL Server 2005.

View 4 Replies View Related

DataRead Of Stored Procedure Returns Column Name Instead Of Null

Jan 6, 2006

I have a stored procedure like "select * from ThisTable"
I'm doing a dataread like:
Dim val as String = dateRead("column_from_ThisTable")
If the value in the column is not null everything works great, but if the value is null, instead of getting a value of "" which I expect, I get the column name??? In this case "column_from_ThisTable"
How do I make sure I get "" returned when the value in the column is db.null?

View 3 Replies View Related

Transact SQL :: Table Valued Function Returns Nothing When Single Column Selected

Apr 21, 2015

We run std 2008 r2.  I haven't looked at my friend's function closely yet bur he showed me that when he selects from the function with one column and the same where clause he uses on same func with select *, he gets no data under the column he requested. 

But when he selects * he gets a single row.

I took a peek and see a bunch of left joins followed by a bunch of outer applies in his func. I suppose (thinking out load) if anything random like the order of rows returned or sql decisions on how query runs can affect his function, that might explain it.  

View 8 Replies View Related

Problem In Executing Stored Procedure With Temp Table Returns Result Sets

Mar 23, 2006

Hi,
we are facing problem in executing a stored procedure from Java Session Bean,

coding is below.

pst = con.prepareStatement("EXEC testProcedure ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
pst.setString(1, "IN");
//
rs = pst.executeQuery();
rs.last();
System.out.println(" Row Number "+rs.getRow());
rs.beforeFirst();
while(rs.next())
{
System.out.println(" Procedure is "+rs.getString(1));
}

same sp working perfectly with SQL Server 2000

am getting a error message

com.microsoft.sqlserver.jdbc.SQLServer
Exception: A server cursor cannot be opened on the given statement or statements
. Use a default result set or client cursor.



If a SP doesnt have a temp table, then there is no issue, SP executes perfectly, but if a SP has a temp table, this error occurs.

SP :

create proc testProcedure
@countrCode varchar(3)
as

select countryname INTO #TMPCOU from country where countryCode = @countrCode
SELECT COUNTRYNAME FROM #TMPCOU

Its really very urgent. Please help me...!

Rgds,

Venkatesh.

View 2 Replies View Related

SQL Server VARCHAR(MAX) Column Returns Error While Inserting Records Into Table(ODBC Driver: SQL Native Client)

Aug 15, 2007

I created very simple table with 3 columns and one is varchar(max) datatype

When i insert records thru VC++ ADO code i am getting this error



Exception Description Multiple-step OLE DB operation generated errors. Check e
ach OLE DB status value, if available. No work was done. and Error Number:: -2147217887



ODBC Driver: SQL Native Client

SQL server 2005



Table

CREATE TABLE [dbo].[RAVI_TEMP](

[ID] [int] NULL,

[Name] [varchar](max) NULL,

[CITY] [varchar](50) NULL

)



VC++ code

#include "stdafx.h"
#include <string>
#include <strstream>
#include <iomanip>


int main(int argc, char* argv[])
{
try
{
HRESULT hr = CoInitialize(NULL);
_RecordsetPtr pExtRst = NULL;
_bstr_t bstrtDSN, bstrtSQL;
bstrtDSN = L"DSN=espinfo;UID=opsuser;PWD=opsuser;";
bstrtSQL = L"SELECT * FROM RAVI_TEMP";

_variant_t vartValueID,vartValueNAME,vartValueCITY;
_bstr_t bstrtValueID,bstrtValueNAME,bstrtValueCITY;

pExtRst.CreateInstance(__uuidof(Recordset));
hr = pExtRst->Open(bstrtSQL, bstrtDSN, adOpenDynamic, adLockOptimistic, adCmdText);

hr = pExtRst->AddNew();

bstrtValueID = L"1";
vartValueID = bstrtValueID.copy();

bstrtValueNAME = L"RAVIBABUBANDARU";
vartValueNAME = bstrtValueNAME.copy();

bstrtValueCITY = L"Santa Clara";
vartValueCITY = bstrtValueCITY.copy();

pExtRst->GetFields()->GetItem(L"ID")->Value = vartValueID;
pExtRst->GetFields()->GetItem(L"NAME")->Value = vartValueNAME;
pExtRst->GetFields()->GetItem(L"CITY")->Value = vartValueCITY;
pExtRst->Update();
pExtRst->Close();

}
catch(_com_error e)
{
printf("Exception Description %s and Error Number:: %d",(LPTSTR)e.Description(),e.Error());
return e.Error();
}
return 0;
CoUninitialize();
}


if i use regular SQL ODBC driver, no error but its truncating the data



Adv Thanks for your help

View 1 Replies View Related

Db Not Recognised

Sep 10, 1999

I've just reinstalled SQL 7, and it will no longer recognise a .mdf file created last week.

Any ideas ?

View 2 Replies View Related

'last' Is Not A Recognised Function Name

Jul 18, 2006

Hi all,

ive tried to run a query in a view and am getting this error message:

'last' is not a recognised function name

i was sure that last was used in sql, how can i get the same result if it wont accept 'last'?

greg

View 2 Replies View Related

Custom Log Provider - Not Recognised.

Feb 15, 2007

Hi All,

I have a tricky one for you...

1. I create a custom log provider on machine A.

2. I deploy the signed assembly to the../../DTS/90/LogProviders directory & the GAC on both machine A & machine B.

3. I create a new package on machine A & go to enable logging for this new custom provider: I find it in the drop-down list of providers, and I can add it successfully.

4. I create a new package on machine B & go to enable logging for this new custom provider: I find it in the drop-down list of providers, but I can't add it. I get the following error:

'...failed to create log provider...the log provider type "_" specified for log provider "_" is not recognized as a valid log provider type. This occurs when an attempt is made to create a log provider for an unknown log provider type. Verify the spelling in the log provider type name (package)."



Any ideas anyone??

Tamim.

View 5 Replies View Related

Stored Procedure Returns No Value

Mar 1, 2006

Hi,I have a stored procedure (the code is below) that I use to retrieveone value from my database. I tested the code in Query Analyzer, and itworks (I get the value I was looking for). However, when I call thesame code from the stored procedure, I get no value. The code that isexecuted is the same and the input parameter is the same. Does anybodyhave an idea?The code:SELECT Top 1CharID,CharName,CategoryName,CharDescription,UserIDFROM [Character]WHERE CharName='Character'-- returns the right valueThe Stored Procedure:CREATE PROCEDURE SpCharacters_SelectOneByUserName@UserName NVarCharASSELECT Top 1CharID,CharName,CategoryName,CharDescription,UserIDFROM CharacterWHERE CharName=@UserNameGO-- returns no value

View 2 Replies View Related

Binary Column Always Returns 0 For ISNULL

Jan 29, 2007

Why don't i ever get return value of 1 when the following binary column (profSignature) is null? 
RETURN SELECT ISNULL(profSignature, profSignature) FROM mpProfiles WHERE ApplicantID = CAST(@CID AS INT) AND ProfileID = CAST(@PID AS INT)

View 7 Replies View Related

Detecting Carriage Returns In A Column

Jun 12, 2006

Can anyone provide me with some SQL that will identify rows from a table where a varchar column named "Notes" contain Carriage Returns?

I know that with report writer SQR I can translate CR's to white space but I do not know of any Sybase function that will allow me to do the same, any ideas on this well would be appreciated.

View 3 Replies View Related

Concatenated Column Returns Null

Mar 7, 2008

Hi folks,I have an issue with a column I created in my query called Instance.SELECT Object_Id, Event_type, Audience, Subject, Provider, Academic_Year, Start_date, End_date, CONVERT(varchar, Academic_Year) + ' (' + CONVERT(varchar, Start_date, 103) + ') : ' + Event_type AS InstanceFROM EventsORDER BY Event_type Above is my query. The problem is because the start date column can be null, it also returns the Instance column as null for that row.I thought it would have just missed out the date and display the rest, but it doesn't.Is there any way I could get the Instance column to display a value, when the start date is null?ThanksEdit: Managed to sort it using ISNULL()

View 14 Replies View Related

I Want A Query That Returns Only The Column Names

Dec 16, 2007

I want a query that returns only the column names

View 4 Replies View Related

Computed Column Returns Null

Nov 16, 2007

How do you prevent SQL from returning a null value for a computed column?

The following formula returns blank if any of the values are blank ... pftitle allows nulls, the other two are required on Insert.

(((([pflastname]+', ')+[pffirstname])+' - ')+[pftitle])

Where can I find the documentation of computed field operators and expressions?

View 3 Replies View Related

Stored Procedure Returns -1 For A Bit Field

Apr 15, 2008

Hello,I have a stored procedure: -- Get an individual league match by IDALTER PROCEDURE [dbo].[mb_League_GetLeagueMatchByID](   @LeagueMatchID  int)ASSET NOCOUNT ONSELECT * FROM mb_LeagueMatch WHERE mb_LeagueMatch.LeagueMatchID = @LeagueMatchIDThe mb_LeagueMatch table has a column named IsActive that is a bit datatype.The value for all rows is set to true (in database explorer in visual studio 2005).When I execute the above stored procedure I always get -1 (I'm guessing that means null) as a result for IsActive if it was true and 0 when false (as expected).However, when I run a query on the database for the same parameter, I get the expected 1 as the value for IsActive.Has anyone seen this before?Thanks,Howard

View 4 Replies View Related

Stored Procedure Returns Boolean???

Sep 30, 2004

hi,
i just want to check whether the given data exists in the database. i am using stored procedure. is there any way to know whether that value exists in database without the need to select anything?

View 1 Replies View Related

Is It Possible To Have A Stored Procedure That Returns 2 Values?

Oct 5, 2004

Is It possible to have a stored procedure that returns 2 values?
and call it from a C# webforms application.
Thanks.

View 7 Replies View Related

LIKE In Stored Procedure Returns No Record

Jun 29, 2005

I have following stored procedure:
-------------
CREATE PROCEDURE dbo.Test
@name as char(36)

as

select a, b
from testtable
where name LIKE @name +'%'
------------

when I run the select statement from query analyzer,

select a, b from testtable where name LIKE 'a%'

it returns records.

But when I call the stored procedure from query analyzer,

exec Test 'a'

it returns no record.

What might be wrong?

Any help is appreciated.

View 3 Replies View Related

Procedure Returns Wrong @@Identity

Jan 15, 2004

Hi,

I have a procedure that inserts a record to a table and return the @@Identity as an output parameter.

This table has a trigger that is triggered when a record is inserted and add a new record to other table.

The problem is that the @@Identity returned is totally wrong.

Any ideas?

Thanx in advance.

View 3 Replies View Related

How Many Records A Stored Procedure Returns?

Oct 11, 2007

Hi,
I need to know whether a stored procedure returns only a single record or it can return more than one if the query if for example to return all records in a specific date range.
Thanks.

View 6 Replies View Related

SQL Stored Procedure Returns Duplicates

Mar 23, 2007

I am new to SQL and SQL Server world. There must be a simple solutionto this, but I'm not seeing it. I am trying to create a crystalreport (v8.5) using a stored procedure from SQL Server (v2000) inorder to report from two databases and to enable parameters.When I create the stored procedure, it joins multiple one-to-manyrelationship tables. This results in repeated/duplicate records. Isthis an issue that should be solved within the stored procedure, or isthis inevitable? If latter, how do you eliminate the duplicates inCrystal Reports?Let's say we have three different tables - Event, Food, Equipment.Each event may have multiple food and multiple equipments; some eventsmay not have food and/or equipments. The stored procedure outcome maylook like this:Event Food Food_Qty EquipmentEquipment_QtyEvent1 Food2 10 Equipment51Event1 Food4 10NULL NULLEvent2 Food4 50 Equipment210Event2 Food4 50 Equipment52Event2 Food1 12 Equipment210Event2 Food1 12 Equipment52As you can see in Event2, for each Food variations, Equipment valuesrepeat. When I am creating a Crystal Reports, I have the duplicationproblem.What I would like to see in the report is either:Event1Food2, 10 Equipment5, 1Food4, 10Event2Food4, 50 Equipment2, 10Food1, 12 Equipment5, 2OR:Event1Food2, 10Food4, 10Equipment5, 1Event2Food4, 50Food1, 12Equipment2, 10Equipment5, 2Attempt1: Using "Eliminate Duplicate Record" option does not work withthe Equipment section since CR does not recognize "Equipment2" in thethird line of the table and "Equipment2" in the fifth line of thetable as duplicates.Event1 Food2, 10 Equipment5, 1Food4, 10Event2 Food4, 50 Equipment2, 10Equipment5, 2Food1, 12 Equipment2, 10(duplication)Equipment5, 2(duplication)Attempt2: I created group for each category (Event, Food, Equipment),put the data in Group Headers and used "Suppress Section" to eliminateif the same equipments are listed more than once within the Foodgroup. This eliminated the duplication, but the items do not aligncorrectly.Event1 Food2, 10 Equipment5, 1Food4, 10Event2 Food4, 50 Equipment2, 10Equipment5, 2Food1, 12 (I want this to appear right below the'Food4, 50' line)I would really appreciate any suggestions! Thank you in advance.

View 4 Replies View Related

Stored Procedure Returns Duplicates

Apr 10, 2007

I am trying to create a report in Crystal Reports (v 8.5). I have astored procedure to pull data from two databases and parameters.There are multiple one-to-many relationships and the stored procedurereturns duplicates; e.g., one schedule may have multiple resources,supplies, and/or orders (and one order may have multiple foods). Isthere a way to stop the duplication?The stored procedure looks like this:************************************************** **********************************SET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS OFFGOCREATE PROCEDURE usp_rpt1 (@start_date smalldatetime,@end_date smalldatetime,@rpt_type varchar(3),@rpt_id int)ASset nocount on--Set up some string variables to build the selection query for theparameters supplieddeclare @fields varchar(255)declare @tables varchar(255)declare @where varchar(2000)CREATE TABLE #tmp_sched(sched_id int, rpt_type_desc varchar(100),rpt_id int)set end_date = midnight of next daySELECT @end_date = DATEADD(day,1,@end_date)SELECT @end_date = CONVERT(smalldatetime,CONVERT(varchar(4),YEAR(@end_date)) + '-'+CONVERT(varchar(2),MONTH(@end_date)) + '-'+CONVERT(varchar(2),DAY(@end_date))IF @rpt_type = 'LOC'INSERT INTO #tmp_schedSELECT DISTINCT s.sched_id, l.loc_desc, l.loc_idFROM tbl_sched sLEFT JOIN tbl_sched_res_date srd ON s.sched_id = srd.sched_idLEFT JOIN tbl_res r ON srd.res_id = r.res_idLEFT JOIN tbl_grp g ON r.grp_id = g.grp_idLEFT JOIN tbl_loc l ON g.loc_id = l.loc_idWHERE l.loc_id = CONVERT(varchar(12),@rpt_id)AND g.obsolete_flag = 0AND r.obsolete_flag = 0ANd l.obsolete_flag = 0AND s.deleted_flag = 0AND srd.mtg_start_date_local >=CONVERT(varchar(20), @start_date, 1)AND srd.mtg_start_date_local <CONVERT(varchar(20), @end_date+1,1)IF @rpt_type = 'GRP'INSERT INTO #tmp_schedSELECT DISTINCT s.sched_id, g.grp_desc, g.grp_idFROM tbl_sched sLEFT JOIN tbl_sched_res_date srd ON s.sched_id =srd.sched_idLEFT JOIN tbl_res r ON srd.res_id = r.res_idLEFT JOIN tbl_grp g ON r.grp_id = g.grp_idWHERE (g.grp_id = CONVERT(varchar(12),@rpt_id)OR g.parent_grp_id =CONVERT(varchar(12),@rpt_id))AND g.obsolete_flag = 0AND r.obsolete_flag = 0AND s.deleted_flag = 0AND srd.mtg_start_date_local >=CONVERT(varchar(20), @start_date, 1)AND srd.mtg_start_date_local <CONVERT(varchar(20), @end_date+1,1)IF @rpt_type = 'RES'INSERT INTO #tmp_schedSELECT DISTINCT s.sched_id, r.res_desc, r.res_idFROM tbl_sched sLEFT JOIN tbl_sched_res_date srd ON s.sched_id =srd.sched_idLEFT JOIN tbl_res r ON srd.res_id = r.res_idWHERE r.res_id = CONVERT(varchar(12),@rpt_id)AND r.obsolete_flag = 0AND s.deleted_flag = 0AND srd.mtg_start_date_local >=CONVERT(varchar(20), @start_date, 1)AND srd.mtg_start_date_local <CONVERT(varchar(20), @end_date+1, 1)IF @rpt_type = 'REG'INSERT INTO #tmp_schedSELECT DISTINCT s.sched_id, reg.region_desc,reg.region_idFROM tbl_sched sLEFT JOIN tbl_sched_res_date srd ON s.sched_id =srd.sched_idLEFT JOIN tbl_res r ON srd.res_id = r.res_idLEFT JOIN tbl_grp g ON r.grp_id = g.grp_idLEFT JOIN tbl_loc l ON g.loc_id = l.loc_idLEFT JOIN tbl_region reg ON l.loc_id = reg.region_idWHERE reg.region_id = CONVERT(varchar(12),@rpt_id)AND reg.obsolete_flag = 0AND l.obsolete_flag = 0AND g.obsolete_flag = 0AND r.obsolete_flag = 0AND s.deleted_flag = 0AND srd.mtg_start_date_local >=CONVERT(varchar(20), @start_date, 1)AND srd.mtg_start_date_local <CONVERT(varchar(20), @end_date+1, 1)IF @rpt_type NOT IN ('LOC','GRP','RES','REG')INSERT INTO #tmp_schedSELECT DISTINCT s.sched_id, g.grp_desc, g.grp_idFROM tbl_sched sLEFT JOIN tbl_sched_res_date srd ON s.sched_id =srd.sched_idLEFT JOIN tbl_res r ON srd.res_id = r.res_idLEFT JOIN tbl_grp g ON r.grp_id = g.grp_idWHERE (g.grp_id = 0 OR g.parent_grp_id = 0)AND g.obsolete_flag = 0AND r.obsolete_flag = 0AND s.deleted_flag = 0AND srd.mtg_start_date_local >=CONVERT(varchar(20), @start_date, 1)AND srd.mtg_start_date_local <CONVERT(varchar(20), @end_date+1,1)--This is the selection for our reportSELECT Description = ts.rpt_type_desc,Date = CONVERT(varchar(12),srd.mtg_start_date_local,101), StartTime = srd.mtg_start_date_local,EndTime = srd.mtg_end_date_local,SchedID = s.sched_id,MeetingTitle = s.sched_desc,ResourceUsed = r.res_desc,ResourceSetup = su.setup_desc + ' (' +CONVERT(varchar(10),rs.capacity) + ')',NumberOfAttendees = Attendees.string_value,OrderID = ord.order_id,FoodQty = CONVERT (int,oi.order_qty),FoodDesc = i.item_name,Side = sidei.item_name,MeetingDesc = ord.order_desc,Supplies = suppliesudf.udf_desc,SuppliesVal = supplies.value,AccountCode = ord.order_user_acct_code,host.string_value as MeetingHost,CateringNotes = ord.order_notes,FoodNotes = oi.order_notesFROM #tmp_sched tsJOIN tbl_sched s ON ts.sched_id = s.sched_idJOIN tbl_sched_res_date srd ON ts.sched_id = srd.sched_idJOIN tbl_res r ON srd.res_id = r.res_idJOIN tbl_sched_res_setup srs ON s.sched_id = srs.sched_id andr.res_id = srs.res_idLEFT JOIN tbl_res_setup rs ON srs.setup_id = rs.setup_id ANDsrs.res_id = rs.res_idLEFT JOIN tbl_setup su ON rs.setup_id = su.setup_idLEFT JOIN tbl_sched_request_tab_val supplies ON s.sched_id =supplies.sched_idAND ((supplies.request_tab_id =(SELECT request_tab_id FROM tbl_request_tab WHERE(request_tab_hdr = 'A) Meeting Supplies')))OR (supplies.request_tab_id =(SELECT request_tab_id FROM tbl_request_tab WHERE(request_tab_hdr = 'Mtg Supplies-PEMC'))))AND (CONVERT(varchar, supplies.value) NOT IN ('0', ''))LEFT JOIN tbl_udf suppliesudf ON supplies.udf_id =suppliesudf.udf_idJOIN tbl_sched_udf_val attendees ON attendees.sched_id = s.sched_idAND attendees.udf_id =(SELECT udf_id FROM tbl_udf WHERE udf_desc = 'Number ofAttendees') --UDF For No of AttendeesJOIN tbl_sched_udf_val host ON host.sched_id = s.sched_idAND host.udf_id =(SELECT udf_id FROM tbl_udf WHERE udf_desc = 'MeetingHost') --UDF For meeting host nameLEFT JOIN RSCatering.dbo.tbl_Order ord ON ord.order_sched_id =s.sched_id --Our link to table in other databaseJOIN RSCatering.dbo.tbl_order_item oi ON ord.order_id =oi.order_idLEFT JOIN RSCatering.dbo.tbl_menu_item mi ON oi.menu_item_id =mi.menu_item_idLEFT JOIN RSCatering.dbo.tbl_item i ON mi.item_id = i.item_idLEFT JOIN RSCatering.dbo.tbl_order_item_sides side ONoi.order_item_id = side.order_item_idLEFT JOIN RSCatering.dbo.tbl_item sidei ON side.item_id =sidei.item_idWHERE ord.deleted_flag = 0 AND oi.deleted_flag = 0ORDER BYts.rpt_type_desc,srd.mtg_start_date_local,srd.mtg_ end_date_local,r.res_descDROP TABLE #tmp_schedGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO************************************************** ****************************************The simplified result looks like:Sched2 Resource1 Supply1 Order5Sched2 Resource1 Supply1 Order6Sched2 Resource1 Supply3 Order5Sched2 Resource1 Supply3 Order6Sched2 Resource2 Supply1 Order5Sched2 Resource2 Supply1 Order6Sched2 Resource2 Supply3 Order5Sched2 Resource2 Supply3 Order6However, I want the result to look like:Sched2 Resource1 Supply1 Order5Sched2 Resource2 Supply3 Order6Any suggestion is greatly appreciated.

View 6 Replies View Related

Stored Procedure Returns Different Data When You Run It In T-SQL

Dec 13, 2007

I have a stored procedure




Code Block
CREATE PROCEDURE WEA_SelectEmployeeListByCourseOrProject
@ProjectID int,
@CourseID int,
@blnIsSearch int,
@strUserName nvarchar(20)

AS
SET CONCAT_NULL_YIELDS_NULL OFF

DECLARE @strRole nvarchar(15),
@ContactID int
SELECT @strRole = Role, @ContactID = ContactID FROM Contact WHERE UserName = @strUserName
Select DISTINCT Contact.ContactID ID, UPPER(Surname + 'gd ' + Forename ) AS Description, UPPER(Surname + ' ' + Forename + ' ' + ContactReference) AS Description_CR
, UPPER(ISNULL(ContactReference,'')) ContactReference
FROM Contact
LEFT JOIN AssignedEmployee on Contact.ContactID = AssignedEmployee.ContactID
WHERE RUEmployee=1
AND
( ((@CourseID = 0 AND @blnIsSearch=1 ) OR COALESCE(AssignedEmployee.CourseID,0) = @CourseID))
AND
(@ProjectID = 0 OR COALESCE(AssignedEmployee.ProjectID,0) = @ProjectID)
AND
(
(@strRole = 'MIS_TUTOR' AND
(AssignedEmployee.ContactID = @ContactID
OR CourseID IN (SELECT CourseID FROM AssignedEmployee WHERE ContactID = @ContactID AND Lead = 1)
OR AssignedEmployee.ProjectID IN (SELECT ProjectID FROM AssignedEmployee WHERE CourseID IS NULL AND Lead = 1 AND ContactID = @ContactID))
)
OR
(@strRole <> 'MIS_TUTOR')
)
SET CONCAT_NULL_YIELDS_NULL ON
GO






now if i run this stored procedure in Query Analyzer like so...

exec wea_SelectEmployeeListByCourseOrProject 0,0,1,'K_T'

i get 48 records returned.

but if i lift the SQL out of the stored procedure and run it in Query Analyzer like so....





Code Block
SET CONCAT_NULL_YIELDS_NULL OFF

DECLARE @ProjectID int,
@CourseID int,
@blnIsSearch int,
@strUserName nvarchar(20)
SET @ProjectID = 0
SET @CourseID = 0
SET @blnIsSearch = 1
SET @strUserName = 'K_T'


DECLARE @Role nvarchar(15),
@ContactID int
SELECT @Role = Role, @ContactID = ContactID FROM Contact WHERE UserName = @strUserName
PRINT @ContactID
Select DISTINCT Contact.ContactID ID, UPPER(Surname + ' ' + Forename ) AS Description, UPPER(Surname + ' ' + Forename + ' ' + ContactReference) AS Description_CR
, UPPER(ISNULL(ContactReference,'')) ContactReference
FROM Contact
LEFT JOIN AssignedEmployee on Contact.ContactID = AssignedEmployee.ContactID
WHERE RUEmployee=1
AND
( ((@CourseID = 0 AND @blnIsSearch=1 ) OR COALESCE(AssignedEmployee.CourseID,0) = @CourseID)) -- the above line was modified to make sure only employees explicitly assigned to a project are brought back. unless it's a search
AND
(@ProjectID = 0 OR COALESCE(AssignedEmployee.ProjectID,0) = @ProjectID)
AND
(
(@Role = 'MIS_TUTOR'
AND ( (AssignedEmployee.ContactID = @ContactID OR CourseID IN (SELECT CourseID FROM AssignedEmployee WHERE ContactID = @ContactID AND Lead = 1)))
OR
AssignedEmployee.ProjectID IN (SELECT ProjectID FROM AssignedEmployee WHERE CourseID IS NULL AND Lead = 1 AND ContactID = @ContactID)
)
OR
(@Role <> 'MIS_TUTOR')
)


SET CONCAT_NULL_YIELDS_NULL ON







i only get 5 records returned???

so why do i get a difference when its the same SQL??

Username 'K_T' is of role 'MIS_TUTOR' therefore @Role = 'MIS_TUTOR'

any help on unravelling this mystery is appreciated!

Cheers,
Craig

View 5 Replies View Related

Sql Query To Update A Column When The Subquery Returns More Than One Row

Oct 6, 2006

Hi People,

I am having a table which has some 10 cols, only one column had all Nulls. DB-SQL2K5

I am now writing a query like

Update Test1

set Id =

(Select t2.Id from

Test2 t2, Test1 t1

where

t2.Name = t1.Name)

as likely this query is faling as the sub query is retuning more than a row. What is the best method to achive my requirement?

Thanks

View 7 Replies View Related

How Do You Format A Column Heading To Use Carriage Returns?

Mar 12, 2008



In SSRS/RDL, How do you format a column heading to use carriage returns?

I have a couple of instance where I have a column heading that I want spread over 3 lines. For example, the column heading "= Actual Amount" I would want centered and displayed on 3 lines, as follows:

=
Actual
Amount

View 4 Replies View Related

Find A Function That Returns The Column Width

Mar 3, 2008


Dear all hi,

I would like to create a function that will return to me the width of the column of the table without giving as a parameter the table name. I need it, as I want to exceed my data in this column to the column length. I want to fill the column data with trailing blanks until I reach the column width. The function len returns the length of the data in the column.

I know that If I have the table name I can find the column width through the system tables. I don€™t want this.

Sincerely,
Hellen

View 10 Replies View Related

Any Function That Returns The Position Of A String In A Column?

Dec 12, 2007

Hello!
Is there a function that gets the name of a column and a string as arguments and returns the position of this string in the column given?

Thank you in advance.

View 1 Replies View Related

Incompatible Datatype?? Varchar(50) Not Recognised As String?

Jun 15, 2008

 here is my code snippet 
 
Session("matricN") = Trim(TextBox1.Text)
 Dim txtValue As String
        txtValue = Session("matricN")       
 da = New SqlDataAdapter("select MatricNumber,Name, Roles from Register where MatricNumber = " & txtValue, addRoleConn1)
 
MatricNumber is in varchar(50) datatype,, the errror says there is a syntax near "="

View 1 Replies View Related

Failover Partner Keyword Not Recognised With OLEDB

May 10, 2007

Hi



Sincere Apologies for the cross posting. Did not realize that there is a specific DB Mirroring group and so posted initially in the High Availability group. Here is the original post



Hi



I am trying to test DB Mirroring connectivity and running into a road block. using SQLOLDB in my connection string the failover partner keyword seems to be not recognised when the failover occurs and the connectivity fails. The same however works with the SQL Native client driver.



Can any expert please let me know what I am doing wrong and what is the right connection string for the OLEDB one?. I also tried using different flavors of FailoverPartner (like Failover Partner, FailoverPartner etc) to make it work with OLEDB but still could not connect with SQLOLEDB provider.



SQLNCLI works with no issues at all.





Connection string code samples included.



--Code that does not work






Code Snippetconnstring = "Provider=SQLOLEDB;network=dbmssocn;Data Source=Server1SQLInst1;FailoverPartner=Server2SQLInst2;Initial catalog=mydb;INTEGRATED SECURITY=SSPI;"





Code Snippetconnstring = "Provider=SQLNCLI;network=dbmssocn;Data Source=Server1SQLInst1;FailoverPartner=Server2SQLInst2;Initial catalog=mydb;INTEGRATED SECURITY=SSPI;"





Any help is appreciated.



Thanks



AK

View 3 Replies View Related

Calling SQL 2005 Stored Procedure That Returns A Value

Apr 14, 2007

I have a stored procedure on a SQL server, which is workign correctly to check some date/time parameters and then insert a row into a log table.
I am calling it from an ASP page.   Initially I just called it and didn't worry about the return value.  However the Stored procedure now will return a value to determine if it made the change or not and if not why (ie log entry was at incorrect time etc).
 I woudl liek to capture this returned value in my code to display a message to the user but am havign problems finding the right way to get the value.
I am calling the SP as follows:
     Shared Sub createlogentry(ByVal ID, ByVal tme, ByVal val)        Dim result As String        Dim cs As String = ConfigurationManager.ConnectionStrings("connecttion1").ToString        Using con As New System.Data.SqlClient.SqlConnection(cs)            con.Open()            Dim cmd As New System.Data.SqlClient.SqlCommand()            cmd.Connection = con            cmd.CommandType = Data.CommandType.StoredProcedure            cmd.CommandText = "CreateLogEntry"            cmd.Parameters.Add("@ChID", Data.SqlDbType.Int)            cmd.Parameters("@ChID").Value = ID            cmd.Parameters.Add("@Value", Data.SqlDbType.Int)            cmd.Parameters("@Value").Value = val            result = cmd.ExecuteNonQuery().ToString        End Using    End Sub
 
I have tried amending the ExecuteNonQuery line to ExecuteReader()
 Any help appreciated
Regards
Clive

View 3 Replies View Related

Calling A Stored Procedure That Does An Insert And Returns One Value

Feb 3, 2004

Hi !

I have trying to do an insert with a subroutine that calls a stored procedure, but it doesn’ t run. The page loads properly but nothing is inserted in the table of the database, no errors appears after submit the form.
<asp:Button id="SubmitButton" OnClick="Send_data" Text="Submit" runat="server"/>

Here is the code:


Sub Send_data(Sender As Object, E As EventArgs)

Dim CmdInsert As New SqlCommand("new_user1", strConnection)
CmdInsert.CommandType = CommandType.StoredProcedure

Dim InsertForm As New SqlDataAdapter()
InsertForm.InsertCommand = CmdInsert

CmdInsert.Parameters.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.bigint, 8, "User_id"))
CmdInsert.Parameters("@RETURN_VALUE").Direction = ParameterDirection.ReturnValue

CmdInsert.Parameters.Add(New SqlParameter("@e_mail", SqlDbType.varchar, 50, "e_mail"))
CmdInsert.Parameters("@e_mail").Value = mail.Text()

End Sub


What it lacks?

View 3 Replies View Related

Calling A Stored Procedure, Returns Empty

Nov 30, 2005

hi, im new to this site so i don't know if i'm posting in the correct forum. anyway, this is my code:---Dim dbMac As DBLibrary = Nothing
dbMac = New DBLibrary(General.GetMACConnectionString)dbMac.OpenConnection("SPR_STAFFMAIN_GETEMPLOYEERECORDS")dbMac.CreateParameter("@USERENTITYID", GetUserEntityID(), Data.SqlDbType.Int)drpEmpNumbers.DataSource = dbMac.GetDataView("StaffMaintenance")gridStaffMaintenance.DataSource = dbMac.GetDataView("StaffMaintenance")gridStaffMaintenance.DataBind()---DBLibrary is a class that opens a connection to the SQL server. i'm getting an empty grid even though the stored procedure returns a row when i test it in the analyzer. is there to debug or test this code? thanks!

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved