January 10, 2019 at 8:14 pm
Comments posted to this topic are about the item The Identity Select
January 10, 2019 at 10:08 pm
Nice one to end the week on, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
January 11, 2019 at 2:11 am
Elegant!
- Yet, if I only wanted to add an identity column, in order to keep the table name (and save on storage), I would use simply
ALTER TABLE dbo.Names
ADD id INT IDENTITY(1, 1)
January 11, 2019 at 3:08 am
thought it would error so tested and was pleasantly surprised,
will have to remember this one for future
thanks Steve
---------------------------------------------------------------------------------------
The more you know, the more you know that you dont know
January 11, 2019 at 7:37 am
Very interesting, but again it gets me thinking - I hate when that happens.... 🙂
What is the difference between these 2 variations of today's QOD and how would you change the first one to make it as good at the second. Of course I'm talking about field length.
SELECT IDENTITY(INT, 1,1) AS id,bt.FirstName
INTO CustomerNames
FROM (SELECT * FROM (VALUES ('Steve'), ('Andy'), ('Brian')) AS Names(FirstName)) AS bt
---------------
CREATE TABLE Names
(firstname VARCHAR(100));
GO
INSERT dbo.Names (FirstName) VALUES ('Steve'), ('Andy'), ('Brian');
GO
SELECT IDENTITY(INT, 1,1) AS id,bt.FirstName
INTO CustomerNames
FROM Names AS bt
The only thing I noticed was varchar(5) as opposed to varchar(100).
January 11, 2019 at 8:32 am
From the identity perspective, I don't think anything. either SELECT INTO is what it does. If you use it from different sources, you might get different results.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply