hello all,
is there a quick way to convert a zipcode of type int, to a 5 character
char value ?
e.g.
declare @zip int
declare @czip char(5)
select @zip = 2109
select @czip = convert(char, @zip)
select @czip
but with @czip = 02109 instead of 2109 ?
thanks in advance 2 1998
Here is one way
declare @zip int
declare @czip char(5)
select @zip = 2109
select @czip = convert(char, RIGHT('00000' + CONVERT(VARCHAR ,@zip),5))
select @czip
Denis the SQL Menace http://sqlservercode.blogspot.com/
select substring(conve rt(char,100000+ 123),2,5)
select substring(conve rt(char,100000+ 1234),2,5)
select substring(conve rt(char,100000+ 12345),2,5)
-----
00123
(1 row(s) affected)
-----
01234
(1 row(s) affected)
-----
12345
(1 row(s) affected) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Keith MacDonald |
last post by:
Hello,
Is there a portable (at least for VC.Net and g++) method to convert text
between
wchar_t and char, using the standard library? I may have missed something
obvious, but the section on codecvt, in Josuttis' "The Standard C++
Library", did not help, and I'm still awaiting delivery of Langer's
"Standard C++ IOStreams and Locales".
Thanks,
|
by: David Williams |
last post by:
Hi all, i have been able to convert an ASCII character to an INT however im
lost as to how to change them back. Cant find anything on the net (though im
probably looking in the wrong places!). Could anyone help me out?
Thanks
Dave
|
by: JJA |
last post by:
I need to show data for the top 3 zipcodes for EACH of the top 5
counties. I feel totally blocked on how to make this work properly.
Here is my code - anything you can suggest will be greatly appreciated:
SET ROWCOUNT 5
DECLARE @tblTopMarkets TABLE (StateCD CHAR(2), CountyCD CHAR(3))
INSERT INTO @tblTopMarkets
select
S.StateCD,
S.CountyCD
|
by: hantie |
last post by:
In my program, for reducing the complexity, the integer was stored as char,
so 2 is stored as '2', which is decimal: 50
Is is possible for me to obtain the integer value of '2' in the program,
i.e. I want to process '2' as int: 2, not int: 50 ?
Sorry for this newbie question.
|
by: Nikhil Patel |
last post by:
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).
Thanks.
-Nikhil
| |
by: Lame Duck |
last post by:
Hi Group!
I have a vector<floatvariable that I need to pass to a function, but
the function takes a float * arguement. That's OK, I can convert by
doing &MyVector.front(), but when I get back a float * from the
function, how to convert that back to a vector?
Thanks in advance!
|
by: Hemant Shah |
last post by:
Folks,
How can I convert date/time/timestamp to an integer?
According to UDB 8.1 docs that I have,
INTEGER('1964-07-20') should return 19640720, but when I run the SQL
statement I get different answer:
# db2 "VALUES INTEGER(CHAR(1964-07-20))"
|
by: rob.ahlberg |
last post by:
I got an integer what I trying to use with allegro function
textout_ex() but it wants an char/char* as arg... And I really don't
know how to cast it to one...
|
by: ssubbarayan |
last post by:
Hi all,
I am trying a program to convert floating point values to a byte array
and printing the same to the screen.The idea behind this is we already
have an existing function which can do byte level parsing what ever
may be the type of data.The data would be coming from an external
environment.When I parse int,char at byte level,I get right
values,where as floating point just prints 0.000000 to the
screen.Given below is a sample program...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |