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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

appending 00 at the end of string data from sql server db

Status
Not open for further replies.

rebeccah2004

Programmer
Nov 20, 2003
17
US
hello. i hope you can help me. this seems pretty straight forward, but i am missing something. i have a column called internala_c and it is 6 chars in the db. we need to append 2 zeros at the end in out vb app. i have this:
spaces_required = (internala_c - Len(tempString))
tempString = tempString & Space(spaces_required) & Mid(rs.Fields(5), 1, internala_c_Len) & "00"

spaces_required = (cusip_mtf - Len(tempString))
tempString = tempString & Space(spaces_required) & Mid(rs.Fields(6), 1, cusip_mtf_Len)

but what is does is this:
306211 00040228AG3
when i need this:
30621100040228AG3

my column positions look like this(i included the 2 surrounding also):
settle_date_mtf = 1
internala_c = 7
cusip_mtf = 17
trantypetextmtf = 26

any input or help would be greatly appreciated!

thank you,
rebecca
 
This bit < & Space(spaces_required)> is adding your spaces. If you don't want spaces, leave that bit out

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
I realise that you have solved your problem but an alternative approach is to get the SQL database to do it for you as follows:

Instead of using a SQL statement that contains:
Code:
SELECT internala_c, .... FROM ....
try
Code:
SELECT internala_c + '00' AS internala_c00, .... FROM ....
This will return a column called internala_c00 that already has the '00' appended to it.

SQL also has quite a range of String functions that can be used in this way and which generally correspond to the VB string functions.

 
wow, thanks for that tip too. i will give that a shot.

everyone is really nice and helpful in these forums. that's really cool.

regards,
rebecca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top