troubleshooting Question

how to add an identity column to an existing table using script

Avatar of Brad Bansner
Brad Bansner asked on
Microsoft SQL Server
2 Comments1 Solution325 ViewsLast Modified:
I have an existing ASP script which generates a new table, by doing a CREATE TABLE statement, a bunch of columns, then at the end:

lm_index INT IDENTITY (1, 1) NOT NULL

...which creates an integer column called lm_index, as an identity column, auto-increment beginning with 1. Works great.

However, now I have a need to add this same exact type of column to an existing table. Can that be done just as easily?

Sorry if this is a very basic question, but I need to do this the right way the first time, and building/altering tables via a script is not something I do very often.

Thank you!
ASKER CERTIFIED SOLUTION
JestersGrind

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros