Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Question about converting bigint field to int field
We made a poor decision a long time ago when designing our database
structure.  We used bigint data types as the identity keys for many of
our base tables.  For many reasons I would like to change these fields
to int at the largest.  The largest data in these fields is around
200,000.  I know that int can easily store this.

What should I be worried about when changing these fields from bigint
to int?  If anything.  Your help is appreciated.  I did several
searches without much luck.


Report this thread to moderator Post Follow-up to this message
Old Post
mamorgan1@gmail.com
01-20-06 02:23 PM


Re: Question about converting bigint field to int field
I think you've covered the one biggy - make sure your existing data will
fit!

Others...

a)    Make sure anything you join with are the same type, basically make
sure you change it everywhere including your foreign keys table.
b)    Remember to do the stored procedures, udfs, triggers that may use them
as parameter.
c)    You'll need to drop any constraints on your column definied with the
identity property, see example problem...

drop table t

create table t (
mycol bigint identity primary key,
t char(1) )

insert t ( t) values( 'a' )

alter table t alter column mycol int not null

Tony.

--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials


<mamorgan1@gmail.com> wrote in message
news:1137768775.133857.115810@g44g2000cwa.googlegroups.com...
> We made a poor decision a long time ago when designing our database
> structure.  We used bigint data types as the identity keys for many of
> our base tables.  For many reasons I would like to change these fields
> to int at the largest.  The largest data in these fields is around
> 200,000.  I know that int can easily store this.
>
> What should I be worried about when changing these fields from bigint
> to int?  If anything.  Your help is appreciated.  I did several
> searches without much luck.
>



Report this thread to moderator Post Follow-up to this message
Old Post
Tony Rogerson
01-20-06 06:23 PM


Re: Question about converting bigint field to int field
Just curious... What problems are there with having bigint as an
identity column?


Report this thread to moderator Post Follow-up to this message
Old Post
pb648174
01-24-06 01:24 AM


Re: Question about converting bigint field to int field
There aren't any problems - it works just fine.

--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials


"pb648174" <google@webpaul.net> wrote in message
news:1138052526.544803.80680@z14g2000cwz.googlegroups.com...
> Just curious... What problems are there with having bigint as an
> identity column?
>



Report this thread to moderator Post Follow-up to this message
Old Post
Tony Rogerson
01-24-06 08:23 AM


Re: Question about converting bigint field to int field
I think its because
Bigint takes 8 bytes storage and Int takes 4 bytes.
SQL Server will not automatically promote other integer data types
(tinyint, smallint, and int) to bigint.

Regards
Amish Shah


Report this thread to moderator Post Follow-up to this message
Old Post
amish
01-24-06 12:23 PM


Re: Question about converting bigint field to int field
> What problems are there with having bigint as an identity column?

extra storage space causing slower performance of everything


Report this thread to moderator Post Follow-up to this message
Old Post
Alexander Kuznetsov
01-24-06 06:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 04:05 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006