[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Having 2 parameters equate to one parameter

I would like to take two parameters in SQL with SQL Server and concatenate them to be passed to one varchar parameter.  How would I take the two parameters, which must take user input and then pass it all to a larger stringed parameter which essentially gets used into the query?  Thanks!
0
VBBRett
Asked:
VBBRett
2 Solutions
 
James MurrellProduct SpecialistCommented:
0
 
VBBRettAuthor Commented:
OK, I am looking for something much simpler then that.  Let's say I have the following:

@cn as varhcar(6)
@mn as varchar(5)

cmn as varchar(12) = @cn + '-' + @mn

How would I declare cmn so that it is not a required parameter for a user to fill in but it is still used in my query?
0
 
mcp111Commented:
declare @cmn varchar(12)
set @cmn=@cn + '-' + @mn

0
 
Aaron ShiloCommented:
create procedure MyProc
(@cn as varhcar,
@mn as varchar)
as
begin
declare @cmn varchar(12)
set @cmn=@cn + '-' + @mn
....bla bla bla
end
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now