473,836 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SELECT @error_message vs SET @error_message

13 New Member
In my SP, I am using SELECT @error_message= 'string' . My collegue asked me to use SET@error_messa ge= 'string' ,
I would like to know the differences for using SELECT vs SET.

Here's the snippet of SP :

set ANSI_NULLS ON
set QUOTED_IDENTIFI ER ON
GO

ALTER PROCEDURE [dbo].[spd_name_of_sp]

(

@fileID Integer
)
as
BEGIN
SET NOCOUNT ON
-- DECLARE variables AND SET default values:
DECLARE @error int,
@error_message varchar(400)

SELECT @error = 0
SELECT @error_message = ''

-- Validate input parameters, AND apply default values as required:
IF @fileID = 0
BEGIN
SELECT @error_message = 'ERROR : File ID must be supplied.'
GOTO HANDLE_ERROR
END

DELETE FROM table
WHERE drf_file_id = @fileID

SELECT @error = @@ERROR
IF @error <> 0 GOTO HANDLE_ERROR

END_OF_PROC:
GOTO EXIT_PROC

HANDLE_ERROR:
IF @error_message = ''
BEGIN
SELECT @error_message = spd_name_of_sto red_procedure failed'
END

-- Raise error passes control immediately to .NET calling application.
RAISERROR(@erro r_message,16,1) WITH NOWAIT

EXIT_PROC:
END
Apr 15 '08 #1
3 6429
ck9663
2,878 Recognized Expert Specialist
Here's a nice read.

-- CK
Apr 15 '08 #2
iitt2007
13 New Member
Nice article. Thanks CK.
Apr 15 '08 #3
siva538
44 New Member
Really nice one. Thanks CK for posting this. A must read by every SQL guy.
Apr 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

49
2662
by: Lauren Wilson | last post by:
Hi folks, Just wondered if, for the sake of clarity, it is permissible to post small image files of an error box along with a text message about a problem with Access?
1
1652
by: Kenny | last post by:
Hi, Is it possible to call a function from a control, for e.g <asp:requiredfieldvalidator id="test" errormessage="ccc" /> Is it possible for me to create a FormatErrorMessage function if I want to change the text of the message. <asp:requiredfieldvalidator id="test" errormessage="<% FormatErrorMessage('test','Invalid input') %>" />
0
1389
by: Edmilson | last post by:
Hi, I´m using a server function in a CustomValidator control to verify a field date content before an insert process. What should I do to avoid the continuation of the process when the errormessage occurs ? tks ed
2
3317
by: Arjen | last post by:
Hello, I have a table record with two validators. The can not be both false. When the first one will be false the errormessage will be placed at the left side of the record. When the second one will be false then the errormessage will be placed at the center of the record. That's the place where the first one will end if it was false too.
1
1788
by: Dorte | last post by:
Hi I am using a customvalidator to perform server validation of user input in webform1. When the user input has been validated, webform1 (which has the customvalidator and the user input) opens a new window (by adding a script to the web page that opens a new window by using response.write), redirects to webform2 in the new window. If user input is invalid, the error message of the customvalidator is displayed on webform1 and there is no...
4
10054
by: James | last post by:
Hello, I have a RequiredFieldValidator for several textbox controls on a form. Here's an example with the RequiredFieldValidator. EnableClientScript, Enabled, and Visible are set to true for the RequiredFieldValidator. <asp:textbox id="FirstName" MaxLength="25" runat="server"></asp:textbox>
3
1585
by: Diffident | last post by:
Guys, Does anyone have any clues about this stack trace? What can be the reason for this error? Is it something related to viewstate? Can I do anything at the application-level by making code changes to prevent this happening again? This error pops out when I click a particular button.....but error is not persistent in all the cases it is sporadic and happens once in 6-7 times
1
2251
by: sab | last post by:
Hi, We have a web form with a listbox. The listbox is a multiple select listbox and has data that looks something like: ALL Unit 1 Unit 2 Unit 3 Note: "ALL" is always the first item in the list.
2
1891
by: PeterKellner | last post by:
I'm wanting to just show the error in a ValidationSummary control, not next to the actual TextField I'm putting a RequiredFieldValidator next to. I don't even want the little "*" showing which field it is. (strange requirement, but that's the way it is). I've found that if I set the attribute Text="" (zero length string), it always uses the ErrorMessage instead of Text. I need the ErrorMessage because that is what is going to show up...
1
1122
by: paul.hester | last post by:
Hi all, Is there any way to customize the error message display with validators. For example, with the following snippet: <tr> <td> <asp:RequiredFieldValidator runat="server" ControlToValidate="userName" Display="Dynamic" EnableClientScript="false" ErrorMessage="Please enter your
0
10840
Oralloy
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...
0
10546
jinu1996
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...
0
10254
tracyyun
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...
0
9371
agi2029
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...
1
7790
isladogs
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...
0
6978
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();...
0
5647
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...
1
4448
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
3
3112
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.