<p>Trying to make a MySQL-based application support MS SQL, I ran into the following issue:</p>

<p>I keep MySQL's auto_increment as unsigned integer fields (of various sizes) in order to make use of the full range, as I know there will never be negative values. MS SQL does not support the unsigned attribute on all integer types, so I have to choose between ditching half the value range or creating some workaround.</p>

<p>One very naive approach would be to put some code in the database abstraction code or in a stored procedure that converts between negative values on the db side and values from the larger portion of the unsigned range. This would mess up sorting of course, and also it would not work with the auto-id feature (or would it some way?).</p>

<p>I can't think of a <em>good</em> workaround right now, is there any? Or am I just being fanatic and should simply forget about half the range?</p>

<p><i>Edit:<br>
@Mike Woodhouse: Yeah, I guess you're right. There's still a voice in my head saying that maybe I could reduce the field's size if I optimize its utilization. But if there's no easy way to do this, it's probably not worth worrying about it.</i></p>

[{'answer_id': 29697, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 0, 'selected': False, 'text': '<p>I would say this.. "How do we normally deal with differences between components?"</p>\n\n<p><strong>Encapsulate what varies</strong>..</p>\n\n<p>You need to create an abstraction layer within you data access layer to get it to the point where it <em>doesn\'t care</em> whether or not the database is MySQL or MS SQL..</p>\n'}, {'answer_id': 29804, 'author': 'Mike Woodhouse', 'author_id': 1060, 'author_profile': 'https://Stackoverflow.com/users/1060', 'pm_score': 2, 'selected': True, 'text': '<p>When is the problem likely to become a real issue?</p>\n\n<p>Given current growth rates, how soon do you expect signed integer overflow to happen in the MS SQL version?</p>\n\n<p>Be pessimistic.</p>\n\n<p>How long do you expect the application to live?</p>\n\n<p>Do you still think the factor of 2 difference is something you should worry about?</p>\n\n<p>(I have no idea what the answers are, but I think we should be sure that we really have a problem before searching any harder for a solution)</p>\n'}, {'answer_id': 41255, 'author': 'mrdenny', 'author_id': 4197, 'author_profile': 'https://Stackoverflow.com/users/4197', 'pm_score': 1, 'selected': False, 'text': '<p>I would recommend using the BIGINT data type as this goes up to 9,223,372,036,854,775,807.</p>\n\n<p>SQL Server does not support signed and unsigned values.</p>\n'}]
['https://Stackoverflow.com/questions/29694', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2077/']