SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Concatenation


Concatenation

Author
Message
Sirish-791018
Sirish-791018
Valued Member
Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)

Group: General Forum Members
Points: 68 Visits: 68
If my SP has the following parameters

a="hyderabad" string

b=10.145

c=a+b

I want my storedprocedure to return the value of c?

is it possible to do so.
ps.
ps.
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4039 Visits: 3668
what are the data types of b and c and what is the expected output?



Pradeep Singh
mayank jarsaniya
mayank jarsaniya
Mr or Mrs. 500
Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)

Group: General Forum Members
Points: 550 Visits: 427
IF I have defined right datatypes then

declare @a varchar(100)
declare @b float
declare @c varchar(max)
select @a ='hyderabad'
select @b= 10.145

select @c=@a + cast(@b as varchar(max))

print @c
Jack Corbett
  Jack Corbett
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23932 Visits: 14905
There are 2 ways to return a single value from a stored procedure, as a resultset and as an output parameter and the recommended method would to use an output parameter. Here's are examples the first being returning the value a s a resultset and the second as an output parameter


Create Procedure variable_as_result_set
AS

SET NOCOUNT ON

declare @a varchar(100)
declare @b float
declare @c varchar(max)

select @a ='hyderabad'
select @b= 10.145

select @c=@a + cast(@b as varchar(max))

Select @c AS C

Return



Alter Procedure variable_as_outputparameter
(
@c VARCHAR(MAX) OUTPUT
)
AS

SET NOCOUNT ON

declare @a varchar(100)
declare @b float

select @a ='hyderabad'
select @b= 10.145

select @c=@a + cast(@b as varchar(max))

RETURN

GO
-- Example call of procedure using output paramter
DECLARE @output_param VARCHAR(MAX)

Exec variable_as_outputparameter @c = @output_param OUTPUT

SELECT @output_param





Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search