Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank Space when joining string will a null test

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
Code:
up_client_plan_create_unique_ref
@planid as int,
@client as int 
AS

declare @int int 
declare @plan varchar(50) 
declare @planLead char(1)
declare @num varchar(50)

set @plan = (SELECT plan_inland_revenue_ref from [plan] where plan_ident = @planid)
set @planLead = (SELECT plan_leadref from [plan] where plan_ident = @planid)
set @int= (SELECT plan_clientcount from [plan] where plan_ident = @planid) + 1
set @num = cast(@int as varchar(10))

select @plan,@int,@plan + '/' + ISNULL( @planLead, '') + replicate('0', 4-len(@num)) + @num



I have the following SP

the data in table plan looks like the following

plan_ident , plan_inland_revenue_ref,plan_clientcount,plan_leadref)
1,'ABCDEF',22,NULL
2,'GHIKKL',40,'T'

What IOm hoping the result to look like is the following

where planid = 1

ABCDEF/23

Where planid = 2

GHIKKL/T41

The second part is working,but i get a space after the Dash

ie
ABCDEF/ 23

Chance,

F, G + HH
 
Hi Chance - wrong forum maybe but is there a space in "PlanLead" ?



Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Wrong forum I know, but in VBA, integer values inserted into a string are often inserted with leading and trailing spaces. Just try trimming the right side of the equation (ie 'ABCDEF/'+trim('23')). Might be different depending on the language and app you're using, and if you're using variable or straight numbers. Could be a more efficient solution, but I usually use trim() when I'm plugging numbers in to a string.


[blue]If you're not part of the solution, there's good money to be made in prolonging the problem.[/blue]
 
turned out it was this

declare @planLead char(1)

should of been

declare @planLead varchar(1)

Chance,

F, G + HH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top