Viewing 15 posts - 28,561 through 28,575 (of 49,552 total)
So given the table schema that you posted, which columns are used to determine if a row already exists?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 3:20 pm
h.v.neerven (1/9/2011)
Youre script is indeed correct, but this does affect 0 rows:
INSERT INTO Table2 (C1,C2,C3)
SELECT C1, C2, C3
FROM Table1
WHERE NOT EXISTS (SELECT 1 FROM Table2 WHERE Table1.C2 = Table2.C2...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 3:17 pm
Please post new questions in a new thread. Thanks.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 3:02 pm
The script that I gave you will do exactly what you asked. If that's not what you want, then you need to refine the requirements. The exists checks the combination...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 2:42 pm
SELECT C1, C2, C3
FROM Table1
WHERE NOT EXISTS (SELECT 1 FROM Table2 WHERE Table1.C2 = Table2.C2 AND Table1.C3 = Table2.C3)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 1:47 pm
Tom.Thomson (1/9/2011)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 1:38 pm
What do you define as 'exists'? All columns matching?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 1:29 pm
h.v.neerven (1/9/2011)
I now understand indeed select 1, it is the same as select *, read it on the internet.
No it's not.
SELECT 1 returns the constant value 1 for all rows.
SELECT...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 12:51 pm
That's not the same as your previous query. The previous one compared on multiple columns.
Question is, does the select (ignore the insert for now) return the rows that you want...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 11:36 am
That might work, but it's very bad form. Have a look at the NOT EXISTS construct, which is specifically for finding matching (or non-matching) rows
SELECT <Whatever>
FROM <SomeTable>
WHERE NOT EXISTS...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 7:16 am
It may be in the database, but it's not referenced in the select statement.
The select must be a valid statement on it's own. You can't reference a column in the...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 9, 2011 at 5:38 am
To expand on that, less logic and processing goes into the missing index DMV entries than into the suggestions from DTA (database tuning adivsor) and even that's often questionable.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 8, 2011 at 2:16 pm
tfifield (1/7/2011)
Thanks. I'm looking forward to the next articles..
No need to look forward. The links at the bottom of this article will take you straight to them. These were...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 7, 2011 at 4:20 pm
TalkToLee (1/7/2011)
The higher levels of the index are generally not large enough for fragmentation to matter, and they're far more likely to be in memory where fragmentation doesn't matter.
Make sense...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 7, 2011 at 2:39 pm
Donalith (1/7/2011)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 7, 2011 at 2:36 pm
Viewing 15 posts - 28,561 through 28,575 (of 49,552 total)