This topic is locked

Add text to Auto Inc. key field

6/7/2007 3:16:34 PM
ASPRunnerPro General questions
S
semleon author

OK. I have a SQL2005 db. using asprunner ver 5.
So I have a column called 'rfs'. It is the Primary key and it is an INT column. It is an AutoIncrement field as well.

What I want to do is add 'ORFS' to be begining of each number
So for record '1' it would display 'ORFS1', or for record '23' it would display 'ORFS23'.
I have added the following line to my sql select statement:

select [status],

[rfs],

'ORFS' + right(str([rfs]),(len(str([rfs]))-1)) as orfsid,

[geir],

[wmd],

[request_detail],

[requestor],

[date_requested],

[date_to_ibm],

[date_sow_recv],

[date_to_req],

[date_app_from_req],

[date_sent_for_final],

[date_final_recvd],

[notes]

From [dbo].[gier_data]
but it is putting a space between the 'ORFS' and the '1'. i.e. 'ORFS 1'
Anyone know how I can get rid of the space? Seems to me that my code should work <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=5451&image=1&table=forumtopics' class='bbc_emoticon' alt=':blink:' />

S
semleon author 6/7/2007

Never mind. I went a different route and it worked.
'ORFS' + convert(varchar, [rfs]) as orfsid,