Forums

This topic is locked

Help: Int field..enter 02, it drops the 0.

Posted 30 Apr 2002 17:35:52
1
has voted
30 Apr 2002 17:35:52 Arash Attarzadeh posted:
Runnin SQLServer2000. I have an integer field set for 3 fields in UD...month, day, and year. I want to force these fields to be 2 in length, however when the user submits 2/03/02, it enters into the database as 2/3/2. Is it possible to preserve this prefix?

Also, this one is regarding macros. Say I have about 2k records in a database and add a drop down list box for Yes/No and want to set the default to No. Once it has been set up, it only works for new records entered into the database. Is there an easier way rather than copy/pasting No into all of the previous fields?

Thanks in advance!

Replies

Replied 14 May 2002 10:32:59
14 May 2002 10:32:59 Julio Taylor replied:
1) i'm not sure about SQLServer 2k, but in MySQL there is a 'zerofill' attribute.
2) instead of copying an pasting, just do the following query:

UPDATE table SET fieldname= 'no'

since you're not specifying a WHERE clause, ALL the records in the database will be updated with the value "no" in the fieldname you have specified.

This is of course using MySQL, i'm not sure how it translates into SQLServer, but give it a try anyway./

-- J


P.S. i killed kenny
Replied 14 May 2002 13:51:49
14 May 2002 13:51:49 Viktor Farcic replied:
1. If you want to preserve zeros, use varchar or char as field type.
2. Create and run Update Query.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Runnin SQLServer2000. I have an integer field set for 3 fields in UD...month, day, and year. I want to force these fields to be 2 in length, however when the user submits 2/03/02, it enters into the database as 2/3/2. Is it possible to preserve this prefix?

Also, this one is regarding macros. Say I have about 2k records in a database and add a drop down list box for Yes/No and want to set the default to No. Once it has been set up, it only works for new records entered into the database. Is there an easier way rather than copy/pasting No into all of the previous fields?

Thanks in advance!


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Viktor Farcic

TalkZone Manager

Reply to this topic