Hi, I'm sort of new to Stored Procedures; and I'm building a search
page where there are 9 parameters the user can put in; as little as
1, at most 9.. then it runs the Stored P and looks at the values.
I am using the COALESCE; to skips nulls,... but I'm still not getting
the right results.. either I get 0 or 4000..
CREATE PROCEDURE Sp_Search
(
@AcctNum varchar (100),
@CliId varchar (10),
@CLName varchar (25),
@CFName varchar (25),
@Foundation varchar (100),
@Custodian varchar (255),
@MMgr varchar (255),
@Advisor varchar (50),
@PA varchar (3),
@Status varchar (3),
@rc int output
)
AS
SELECT tblAccounts.Act AccountNum, tblAccounts.Act ClientID,
tblMasterList.M stLName, tblMasterList.M stFName,
tblMasterList.M stFoundationNam e, tblManagerList. Manager,
tblMasterList.M stDTIARep, tblMasterList.M stReconAssignID ,
tblAccounts.Act AcctStatus
FROM ((tblAccounts INNER JOIN tblManagerList ON
tblAccounts.Act MgrID = tblManagerList. MgrID) INNER JOIN
tblCustodian ON tblAccounts.Act CustID = tblCustodian.Cu stIDRSN)
INNER JOIN tblMasterList ON tblAccounts.Act ClientID =
tblMasterList.M stClientID
WHERE tblAccounts.Act AccountNum = COALESCE(@AcctN um,
tblAccounts.Act AccountNum) AND
tblAccounts.Act ClientID = COALESCE(@CliID ,
tblAccounts.Act ClientId) AND
tblMasterList.M stLname = COALESCE( @CLName,
tblMasterList.M stLName) AND
tblMasterList.M stFName = COALESCE(@CFNam e,
tblMasterList.M stFName) AND
tblMasterList.M stFoundationNam e = COALESCE(@Found ation,
tblMasterList.M stFoundationNam e) AND
tblCustodian.Cu stodian = COALESCE(@Custo dian,
tblCustodian.Cu stodian) AnD
tblManagerList. Manager = COALESCE(@MMgr,
tblManagerList. Manager) AND
tblMasterlist.M stDTIARep = COALESCE(@Advis or,
tblMasterList.M stDTIARep) AND
tblMasterlist.M stReconAssignID =COALESCE( @PA,
tblMasterlist.M stReconAssignID ) AND
tblAccounts.Act AcctStatus =COALESCE( @Status,
tblAccounts.Act AcctStatus)
SET @rc = @@ROWCOUNT
Return
GO
Not sure what is missing, but below is what the Query Analyzer comes
out with..
[code:1:0837109d 5b]
EXEC @RC = [TrackingGenX2K].[dbo].[Sp_Search]
@AcctNum, @CliId, @CLName, @CFName, @Foundation, @Custodian, @MMgr,
@Advisor, @PA, @Status, @rc OUTPUT
DECLARE @PrnLine nvarchar(4000)
PRINT 'Stored Procedure: TrackingGenX2K. dbo.Sp_Search'
SELECT @PrnLine = ' Return Code = ' + CONVERT(nvarcha r, @RC)
PRINT @PrnLine
PRINT ' Output Parameter(s): '
SELECT @PrnLine = ' @rc = ' + isnull( CONVERT(nvarcha r,
@rc), '<NULL>' )
PRINT @PrnLine
[/code:1:0837109d 5b]
There is also an error attached now:
[code:1:0837109d 5b]
Server: Msg 134, Level 15, State 1, Line 13
The variable name '@rc' has already been declared. Variable names must
be unique within a query batch or stored procedure.
[/code:1:0837109d 5b]
ANY help would be appreciated.. THANKS!!! :lol: :oops: :D
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com 1 1373
You may want to put this in microsoft.publi c.sqlserver.pro gramming group
Chris
"Compkitty" <co********@yah oo-dot-com.no-spam.invalid> wrote in message
news:42******** @127.0.0.1... Hi, I'm sort of new to Stored Procedures; and I'm building a search page where there are 9 parameters the user can put in; as little as 1, at most 9.. then it runs the Stored P and looks at the values. I am using the COALESCE; to skips nulls,... but I'm still not getting the right results.. either I get 0 or 4000..
CREATE PROCEDURE Sp_Search ( @AcctNum varchar (100), @CliId varchar (10), @CLName varchar (25), @CFName varchar (25), @Foundation varchar (100), @Custodian varchar (255), @MMgr varchar (255), @Advisor varchar (50), @PA varchar (3), @Status varchar (3), @rc int output )
AS
SELECT tblAccounts.Act AccountNum, tblAccounts.Act ClientID, tblMasterList.M stLName, tblMasterList.M stFName, tblMasterList.M stFoundationNam e, tblManagerList. Manager, tblMasterList.M stDTIARep, tblMasterList.M stReconAssignID , tblAccounts.Act AcctStatus
FROM ((tblAccounts INNER JOIN tblManagerList ON tblAccounts.Act MgrID = tblManagerList. MgrID) INNER JOIN tblCustodian ON tblAccounts.Act CustID = tblCustodian.Cu stIDRSN) INNER JOIN tblMasterList ON tblAccounts.Act ClientID = tblMasterList.M stClientID
WHERE tblAccounts.Act AccountNum = COALESCE(@AcctN um, tblAccounts.Act AccountNum) AND tblAccounts.Act ClientID = COALESCE(@CliID , tblAccounts.Act ClientId) AND tblMasterList.M stLname = COALESCE( @CLName, tblMasterList.M stLName) AND tblMasterList.M stFName = COALESCE(@CFNam e, tblMasterList.M stFName) AND tblMasterList.M stFoundationNam e = COALESCE(@Found ation, tblMasterList.M stFoundationNam e) AND tblCustodian.Cu stodian = COALESCE(@Custo dian, tblCustodian.Cu stodian) AnD tblManagerList. Manager = COALESCE(@MMgr, tblManagerList. Manager) AND tblMasterlist.M stDTIARep = COALESCE(@Advis or, tblMasterList.M stDTIARep) AND tblMasterlist.M stReconAssignID =COALESCE( @PA, tblMasterlist.M stReconAssignID ) AND tblAccounts.Act AcctStatus =COALESCE( @Status, tblAccounts.Act AcctStatus)
SET @rc = @@ROWCOUNT
Return GO Not sure what is missing, but below is what the Query Analyzer comes out with..
[code:1:0837109d 5b] EXEC @RC = [TrackingGenX2K].[dbo].[Sp_Search] @AcctNum, @CliId, @CLName, @CFName, @Foundation, @Custodian, @MMgr, @Advisor, @PA, @Status, @rc OUTPUT DECLARE @PrnLine nvarchar(4000) PRINT 'Stored Procedure: TrackingGenX2K. dbo.Sp_Search' SELECT @PrnLine = ' Return Code = ' + CONVERT(nvarcha r, @RC) PRINT @PrnLine PRINT ' Output Parameter(s): ' SELECT @PrnLine = ' @rc = ' + isnull( CONVERT(nvarcha r, @rc), '<NULL>' ) PRINT @PrnLine
[/code:1:0837109d 5b]
There is also an error attached now:
[code:1:0837109d 5b] Server: Msg 134, Level 15, State 1, Line 13 The variable name '@rc' has already been declared. Variable names must be unique within a query batch or stored procedure. [/code:1:0837109d 5b]
ANY help would be appreciated.. THANKS!!! :lol: :oops: :D
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: todd |
last post by:
here is a search tool SP I wrote.
How many times have you wanted to search all your Stored procs or views (in
a
database) for a keyword but couldn't!?
Well now you can! THis can makes life a lot easier for developers.
Would you email me and let me know which part of the world my code is
running in?
|
by: rdlebreton |
last post by:
Hello,
I am looking for help with the following situation.
I have created a simple call tracking system that is integrated
with our accounting / warehousing program in the company. The call
tracking system uses ASP 3.0 and MSSQL 2000 sitting on an Intranet web
server. All appears to be working well with the software. I am
trying to create a search screen to search through the calls based on
different criteria.
|
by: M Wells |
last post by:
Hi All,
I'm wondering if anyone can tell me if it's possible to search for
stored procedures by their contents?
I tend to leave very descriptive notes in stored procedures and
they're beginning to build up in number, so I'm wondering if it's
possible to search in Query Analyzer for stored procedures that
contain certain words / phrases etc.
|
by: Job Lot |
last post by:
My DataGrid is bound to DataSet which contains relationship between two
tables as follows:
SqlHelper.FillDataset(strConn, CommandType.StoredProcedure,
"spSelectClientApplicant", ds, New String() {"Client", "Applicant"})
ds.Relations.Add("Applicants", ds.Tables("Client").Columns("Client_ID"),
ds.Tables("Applicant").Columns("Client_ID"))
grdDetails.DataSource = ds.Tables("Client").DefaultView
|
by: Axel |
last post by:
Is it possible to write a Stored Procedure that takes a string of
search keywords as argument and returns the recordset? At the mo I am
passing the WHERE String as argument.
I got this technique from an Extreme Ultradev tutorial by Rick Curtis
it looked quite ok:
http://www.princeton.edu/~rcurtis/ultradev/tutorial12.html
I have to admit, one of the main reason for passing the WHERE string is
that I do not know how to do the string...
| |
by: Compkitty |
last post by:
Hi, I'm sort of new to Stored Procedures; and I'm building a search
page where there are 9 parameters the user can put in; as little as
1, at most 9.. then it runs the Stored P and looks at the values.
I am using the COALESCE; to skips nulls,... but I'm still not getting
the right results.. either I get 0 or 4000..
CREATE PROCEDURE Sp_Search
(
@AcctNum varchar (100),
|
by: abbylee26 |
last post by:
my page works fine if the db search finds at least one record that
satifies the query.
but if it does not find a match I get the following error message.
Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.
What do I need to change here to make this just display the page with
|
by: red vertigo |
last post by:
HI All,
Can't quite get my head aorund this problem. My knowledge or more
importantly my experience of using T-SQL is small and as a consequence
my stored procedures are basic.
My current project involves simple stored_procs searching/retrieving
Legacy data. Key problem is that in the case of the 'Job' table, the
'Job Number' is an alphanumeric value. Here is the current stored
procedure:
|
by: acw |
last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that
accesses couple tables and runs the extended stored procedure
xp..cmdshell. The goal is to grant users with limited privileges the
right to run the stored procedure but not the rights to directly
access either the referenced tables or the extended stored procedure.
TIA!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |