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

HELP!!!!!!!!!URGENT!!!!!!!!!!!ANSI_PADDING

Status
Not open for further replies.

tlaksh

Programmer
Joined
Feb 25, 2001
Messages
98
Location
US
I am working on MS SQL 7.0. I have a table that has a varchar column that stores codes...like
0022
0023
0029
0030
0031
00320
00321
00322
00323
00324

etc.

Now previously when i queried the table with a simple select statement the result was
22
23
29
30
31
320
321
322
etc.

Then I SET the ANSI PADDING TO ON. BUT when I turn it back to OFF the values do not come back to the old form without the padded zeros.. How can I set them back as they were.

Please HELP....its urgent

Thanks
Laksh.

 
Hi tlaksh
If the values are to be padded by 2 zeros. You can use the command
Update Table_Name SET Column_Name = '00'+ ltrim(rtrim(Column_Name))

Hope this helps

Mukund.
 

Select Str(Code) As Code From Table

will remove the leading zeros. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top