Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by vinaykumar
»
T-SQL
37 posts, Page 2 of 4
««
1
2
3
4
»
»»
T-SQL
Rate Topic
Display Mode
Topic Options
Author
Message
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Tuesday, February 10, 2009 7:51 AM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
I have altered the question to say "easiest way" and I tend to agree with Hugo that a real table would have other constraints on it. However making a copy of a table isn't necessarily something that you worry about people adding data to. It would not have permissions and not likely be known to other people either.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #653726
Cliff Jones
Cliff Jones
Posted Tuesday, February 10, 2009 8:28 AM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 2:31 PM
Points: 3,418,
Visits: 3,438
Good change. Since a select into can cause some undesirable locking behavior it probably wouldn't be the best way to accomplish the task.
Post #653788
GSquared
GSquared
Posted Tuesday, February 10, 2009 8:34 AM
SSCoach
Group: General Forum Members
Last Login: 2 days ago @ 1:45 PM
Points: 15,442,
Visits: 9,572
I think the question was clear enough. But Hugo is right about the variations on the definition of "best".
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #653799
Alvin Ramard
Alvin Ramard
Posted Tuesday, February 10, 2009 8:40 AM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 10:49 AM
Points: 3,035,
Visits: 7,396
GSquared (2/10/2009)
I think the question was clear enough. But Hugo is right about the variations on the definition of "best".
That is why I said this was a poor choice of question and answer. What is "best" is too suggestive and may not have a clear cut answer.
Alvin Ramard
Memphis PASS Chapter
All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.
Post #653810
Lynn Pettis
Lynn Pettis
Posted Tuesday, February 10, 2009 8:42 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
I find if you don't read too much into these questions that they are usually fairly easy to answer. Unfortunately it seems people add a lot of contraints and requirements that aren't even stated.
It was a good question as it brings to the front identity function that some people may not even know about. The QotD is a learning experience, not about best practices or what should or shouldn't be done in a production environment.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #653813
Derek Dongray
Derek Dongray
Posted Tuesday, February 10, 2009 8:44 AM
Ten Centuries
Group: General Forum Members
Last Login: Monday, May 13, 2013 2:04 AM
Points: 1,342,
Visits: 1,946
OK, I learned about the IDENTITY function used with SELECT INTO.
But if I wanted to copy a table, except as a temporary hack, I'd still use 'Create Script..', edit, etc.
Derek
Post #653820
Hugo Kornelis
Hugo Kornelis
Posted Tuesday, February 10, 2009 8:51 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 5:26 AM
Points: 5,296,
Visits: 7,235
Lynn Pettis (2/10/2009)
I find if you don't read too much into these questions that they are usually fairly easy to answer.
Hi Lynnn,
I would
usually
agree. Not in this case, though. When I read the question and saw the answers, I immediately knew that two of the answers could have been correct.
Either the author of the question wrote this question to educate people about the existance of the IDENTITY() function, in which case SELECT INTO would be the expected answer. Or the author expected the readers to know about this and wrote the question to warn about some less published and less well-known side effects, in which case SELECT INTO would obviously have been wrong and CREATE TABLE ... INSERT SELECT would have been right.
Since there is no way to read the mind of the author of the question, I was faced with a 50/50 chance of getting my answer right. I took my chance ... and lost.
And then I took the opportunity to evangelize about those side effects anyway! :D
Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog:
http://sqlblog.com/blogs/hugo_kornelis
Post #653833
Cliff Jones
Cliff Jones
Posted Tuesday, February 10, 2009 8:54 AM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 2:31 PM
Points: 3,418,
Visits: 3,438
I agree Lynn. Many times the discussion is as or more informative than the question. The point is to learn from the exchange.
Post #653840
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Tuesday, February 10, 2009 9:05 AM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
It's not that they add extra constraints, it's often authors are thinking of one thing. One small area they are trying to show and they don't have the same frame of reference that others do.
If you need a quick copy of a table, do you worry about constraints? Some people do, some always would script that, some would never think about it since there wouldn't be a security issue.
There's also a language issue. How do you try to get someone to think in a particular way. I could see why "best" was chosen, since for this person, it might eb the "best way" with the least amount of effort to do this. Might never have caused an issue.
It's good for people like Hugo to raise the debate. It's also good that the questions are here to get you to think about or learn about some new feature in SQL Server.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #653855
Ninja's_RGR'us
Ninja's_RGR'us
Posted Tuesday, February 10, 2009 9:07 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 7:02 PM
Points: 21,376,
Visits: 9,584
Cliff Jones (2/10/2009)
Good change. Since a select into can cause some undesirable locking behavior it probably wouldn't be the best way to accomplish the task.
Not since 6.5. One of those myths that keep hanging around.
Post #653860
« Prev Topic
|
Next Topic »
37 posts, Page 2 of 4
««
1
2
3
4
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.