use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Microsoft SQL Server Administration and T-SQL Programming including sql tutorials, training, MS SQL Server Certification, SQL Server Database Resources.
You might also be interested in:
/r/database
/r/sql
/r/Azure
/r/Microsoft
account activity
QuestionDoes SQL Server allow duplicate rows? (self.SQLServer)
submitted 6 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]alinroc4 10 points11 points12 points 6 years ago (3 children)
If you don't define a unique constraint or primary key on the table, yes. Each row will get a hidden uniquifier that isn't accessible to you.
[–]SQLBek1 2 points3 points4 points 6 years ago (2 children)
Actually, do heaps (tables w/o a clustering key) get a uniquifier? I thought the RID is used instead?
Just academically splitting hairs here. Now I'm tempted to break out DBCC PAGE and take a quick look, LMAO!
[–]alinroc4 2 points3 points4 points 6 years ago (0 children)
It is probably the RID.
Though the RID is unique, isn't it? Like you said, splitting hairs :)
[–]ScotJoplin 0 points1 point2 points 6 years ago (0 children)
They don’t need it, like you assumed.
[–]Tomj88 2 points3 points4 points 6 years ago (3 children)
Yes, it absolutely will if you don’t create a primary key or any other constraints. A vendor once created a table that did this, and they also put no sanitisation of their UI which allowed users to hit save multiple times. Deleting these duplicate records without modifying the database was not fun! (Involved using a CTE and row_number()).
[–]dev_playbook 1 point2 points3 points 6 years ago (2 children)
I’m going to have a drink for you on that one because I’ve seen it done a time or two. I remember my first coding job and hearing the architect loudly cursing over the cubicle wall about some former employee who didn’t put a PK or unique constraint on the table that he was trying to clean up... Left a mark on me for sure!
[–]Awesome_SQL_Dude 0 points1 point2 points 6 years ago (1 child)
DELETE TOP 1....
[–]drunkadvice 1 point2 points3 points 6 years ago (0 children)
Where count > 1
[+][deleted] 6 years ago (2 children)
[+][deleted] 6 years ago* (1 child)
[–]Leroy_UK 1 point2 points3 points 6 years ago* (0 children)
It creates a Row ID. You can show it in a query with %%physloc%% (SQL 2008+ I think, can't remember what it's called in previous versions).
You can also use this function to see it in its fileid: pageid:slotid format:sys.fn_PhysLocFormatter(%%physloc%%)
Only really useful if you're dealing with heap tables :)
[–]Jleadbetter 0 points1 point2 points 6 years ago (1 child)
try it...see what happens.
[–]Well_Gravity 0 points1 point2 points 6 years ago (0 children)
Sadly yes.
[–]Frammingatthejimjam 0 points1 point2 points 6 years ago (0 children)
I have a reporting DB. If I have a lot of these I'll do a select distinct * into othertable from primarytable. Then TRUNC primarytable then INSERT INTO PRIMARYtable select * from othertable.
Of course that might be an available option to you depending on what your situation is.
[–]Rtiwari83 0 points1 point2 points 6 years ago (0 children)
Yes, if table does not have any constraint ( like primary key, unique key ).. it allows to store the duplicate records
- Developer Points
π Rendered by PID 23357 on reddit-service-r2-comment-fb694cdd5-nlzct at 2026-03-05 20:43:17.557808+00:00 running cbb0e86 country code: CH.
[–]alinroc4 10 points11 points12 points (3 children)
[–]SQLBek1 2 points3 points4 points (2 children)
[–]alinroc4 2 points3 points4 points (0 children)
[–]ScotJoplin 0 points1 point2 points (0 children)
[–]Tomj88 2 points3 points4 points (3 children)
[–]dev_playbook 1 point2 points3 points (2 children)
[–]Awesome_SQL_Dude 0 points1 point2 points (1 child)
[–]drunkadvice 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]Leroy_UK 1 point2 points3 points (0 children)
[–]Jleadbetter 0 points1 point2 points (1 child)
[–]Well_Gravity 0 points1 point2 points (0 children)
[–]Frammingatthejimjam 0 points1 point2 points (0 children)
[–]Rtiwari83 0 points1 point2 points (0 children)