Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
macca
Posting Yak Master
146 Posts |
Posted - 2005-06-16 : 05:07:12
|
| I have two values @service and @office in a stored procedure. When the stored procedure is running @service has the value P and @office has the value L. I want to asssign PL to @temp.I have tried it the following way:@temp = @service + @officebut the aove just gives @temp the value P, but does not add on the L.Any Ideas.Thanks,macca |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-16 : 05:14:25
|
| Declare @temp varchar(20)Declare @service varchar(10)Declare @office varchar(10)set @service='P'set @Office='L'Set @temp = @service + @officeSelect @tempMadhivananFailing to plan is Planning to fail |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-16 : 05:27:02
|
quote: Originally posted by macca@temp = @service + @office
did you use a SET or SELECT command to assign the concatenated value to the @temp variable?-ec |
 |
|
|
macca
Posting Yak Master
146 Posts |
Posted - 2005-06-16 : 06:07:08
|
| Here is the code I am using:CREATE PROCEDURE sproc_Macca(@serOff Char(4) OUTPUT)ASDECLARE @Service char(4) DECLARE @Office char(4)SELECT @Service = Service, @Office = Office FROM Service WHERE DeptID = @deptIDSET @serOff = @Service + @OfficeI have also tried using SELECT @serOff but it is also just returning P. |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2005-06-16 : 06:50:22
|
| use varchar instead of char |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-06-16 : 06:55:42
|
| did you check the data size? 4 might not be enough, also declare @deptIDtry:CREATE PROCEDURE sproc_Macca(@deptid varchar(10),@serOff varchar(10) OUTPUT)ASSELECT @Seroff = Service + Office FROM Service WHERE DeptID = @deptID--------------------keeping it simple... |
 |
|
|
macca
Posting Yak Master
146 Posts |
Posted - 2005-06-16 : 07:18:12
|
| jen,Thanks for the reply.this is working but I am getting returned "P L ", there is a space between P and L and a space after L which is causing problems. Do you know how to get rid of the spaces.macca |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-16 : 07:21:24
|
| Use ltrim and rtrimMadhivananFailing to plan is Planning to fail |
 |
|
|
macca
Posting Yak Master
146 Posts |
Posted - 2005-06-16 : 07:34:05
|
| thanks madhivanan. |
 |
|
|
|
|
|