Hello members, This is the SQL SERVER 2005 stored procedure.
It contains the data from the two diff tables. (1)Customer :
Here clpid and cardid are composite primary keys with the identity field.It has storeid as foreign key.
The cardid is to be autogenerated everytime as the new customer is inserted.
I have to put the validations for the
* joindt = currentdate/todaydate
* dob is not greater than today date
* anniverdt is not less than equal to dob (in terms of year) (2)Store :
Here storeid is the primary key. -
-
-
ALTER PROCEDURE CustomerStoredProcedure
-
-
@cardid INT OUTPUT,
-
@clpid INT OUTPUT,
-
@storename varchar(20),
-
@firstname varchar(20),
-
@lastname varchar(20),
-
@joindt datetime,
-
@anniverdt datetime,
-
@dob datetime,
-
-
@frmErrorMessage AS VARCHAR(256) OUTPUT,
-
@RETURNVALUE AS INT OUTPUT,
-
@RETURNID AS INT OUTPUT
-
AS
-
-
DECLARE
-
-
@storeid AS INT
-
-
BEGIN
-
SET NOCOUNT ON
-
-
-
--validation...
-
IF ( @firstname IS NULL OR @firstname = '' )
-
BEGIN
-
SET @RETURNVALUE = -9
-
SET @frmErrorMessage = 'FName is empty'
-
RETURN -9
-
END
-
IF ( @lastname IS NULL OR @lastname = '' )
-
BEGIN
-
SET @RETURNVALUE = -9
-
SET @frmErrorMessage = 'LName is empty'
-
RETURN -9
-
END
-
-
if @DOB<@AnniversaryDate
-
begin
-
Select @frmErrorMessage ="AnniversaryDate cannot be greater then DOB"
-
return -9
-
end
-
if @DOB=@AnniversaryDate
-
begin
-
Select @frmErrorMessage ="AnniversaryDate cannot be equal to DOB"
-
return -9
-
end
-
-
if @DOB>=getdate()
-
begin
-
Select @frmErrorMessage ="DOB cannot be greater then Today's Date"
-
return -9
-
end
-
BEGIN
-
IF EXISTS (select * from storemaster where storename = @storename)
-
select @storeid = storeid from storemaster where storename = @storename
-
-
-
IF EXISTS ( SELECT firstname,lastname,joindt,anniverdt,dob,
-
FROM customermaster WHERE clpid = @clpid and cardid=cardid)
-
BEGIN
-
UPDATE customermaster
-
SET firstname = @firstname,
-
lastname = @lastname,
-
storeid=@storeid,
-
joindt=@joindt,
-
anniverdt=@anniverdt,
-
dob=@dob,
-
-
WHERE clpid= @clpid and cardid=@cardid
-
-
SET @frmErrorMessage = 'Name and other information has been updated'
-
SET @RETURNVALUE = 2
-
END
-
END
-
-
BEGIN
-
IF EXISTS (select * from storemaster where storename = @storename)
-
select @storeid = storeid from storemaster where storename = @storename
-
-
-
IF NOT EXISTS(Select firstname,lastname,address
-
from customermaster
-
where firstname = @firstname,lastname=@lastname)
-
BEGIN
-
INSERT INTO customermaster (firstname,lastname,joindt,anniverdt,dob,introducedby)
-
VALUES (@firstname,@lastname,@joindt,@anniverdt,@dob,@introducedby)
-
SELECT @clpid = SCOPE_IDENTITY()
-
SELECT @cardid= SCOPE_IDENTITY()
-
END
-
ELSE
-
BEGIN
-
Print 'Name already exists'
-
END
-
-
SET @frmErrorMessage = ' Name and other information has been Inserted'
-
SET @RETURNVALUE = 1
-
END
-
-
SET NOCOUNT OFF
-
END
-
-
Pls can anyone checkout my stored procedure as i have created for the first time for the join stored procedure.
It gives me the error but i can't rectify it.
It is too big but can anyone help then it's fine....
I have mentioned how i created my above procedure.
Can anyone also help me to check or put the validations for the date..
Thanxs in advance...waiti ng for solution
Hope to get a suitable reply
0 1724 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft Visual Basic .NET version of this article, see 308049.
For a Microsoft Visual C++ .NET version of this article, see 310071.
For a Microsoft Visual J# .NET version of this article, see 320627.
This article refers to the following Microsoft .NET...
|
by: Thomas R. Hummel |
last post by:
I have a stored procedure that suddenly started performing horribly.
The query plan didn't look right to me, so I copy/pasted the code and
ran it (it's a single SELECT statement). That ran pretty well and used
a query plan that made sense. Now, I know what you're all thinking...
stored procedures have to optimize for variable parameters, etc.
Here's what I've tried to fix the issue:
1. Recompiled the stored procedure
2. Created a new,...
|
by: jaYPee |
last post by:
I have an existing query from MS Access that I want to convert it to
SQL Server Stored Proc. My problem is on how to convert the WHERE
clause.
This is the query from MS Access:
SELECT SchYrSemCourseJoin.SchYrSemCourseID, Students.IDNo,
& ", " & & " " & AS Name,
Program.ProgramTitle, Program.ProgramDesc, SchYrSem.SchYr,
SchYrSem.Sem, SchYrSem.Year, SchYrSem.Section AS Section1,
|
by: Andrew Mayo |
last post by:
Here's a really weird one for any SQL Server gurus out there...
We have observed (SQL Server 2000) scenarios where a stored procedure
which
(a) begins a transaction
(b) inserts some rows into a table
(c) re-queries another table using a subquery which references the
inserted table (correlated or not)
|
by: mooreit |
last post by:
The purpose for my questions is accessing these technologies from
applications. I develop both applications and databases. Working with
Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test
Environments.
What is the purpose of a view if I can just copy the vode from a view
and put it into a stored procedure?
Should I be accessing views from stored procedures?
| |
by: Simon |
last post by:
I have a problem using a stored procedure in C#. Im using SQL2000 and
C# with web parts.
Currently i put the entire sql query in the CommandText. Then it works
correctly and gives the companynames in my column. As u can see below
in the C# code.
I made a Stored Procedure from the query and want to call that instead,
it saves a lot of code in my project.
|
by: Frawls |
last post by:
Hi
I Am am having problems with a stored Procedure that i wrote.
Basically whats happening is that the Stored procedure Runs fine when i
EXECUTE it in SQL Query analyzer.
But when i debug through the application in Visual Studio .NET 2003 the
application an exception when it executes the query.
|
by: yin_n_yang74 |
last post by:
I am trying to create a report in Crystal Reports (v 8.5). I have a
stored procedure to pull data from two databases and parameters.
There are multiple one-to-many relationships and the stored procedure
returns duplicates; e.g., one schedule may have multiple resources,
supplies, and/or orders (and one order may have multiple foods). Is
there a way to stop the duplication?
The stored procedure looks like this:
...
|
by: brwalias |
last post by:
Hi,
using .net 2
sql server 2005
Here is my situation:
I'm passing a variable in the url from a selection on Page A and need
to display the results on the Results page be based on that variable
in the url. I would like that variable to trigger a stored and
|
by: aCe |
last post by:
hi all,
i need to convert these simple PHP code into stored procedure :
<?php
$result = mssql_query( "SELECT whid, whcode FROM warehouse" );
while( $wh = mssql_fetch_object( $result ) )
{
$result = mssql_query( "SELECT plid, nopl FROM packlist WHERE whid =
'" . $wh->whid . "'";
while( $pl = mssql_fetch_object( $result ) )
{
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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...
| |