Hey
I've been doing for SQL for a while but recently I've been trying to get
some whitepaper for it, I'm now working through some questions I obviously
first I google the questions before I came here to ask.
I ran into the questions.
Give an example of a rowbased statement, and a set based statement. I'm sure
know how to code it but I don't know what it is.
Another question I ran into was "what setting do you ALWAYS disable" in a
live environment. Now I don't know this either... it's not a registered
Microsoft exam so I don't know if the questions are dodgy.
Answers would be appreciated though.
THanksHi Mal
Row based statement:
SELECT * FROM <TABLE> WHERE NEWID() = '<some ID>'
SET based statement
SELECT * FROM <TABLE>
best Regards,
Chandra
http://chanduas.blogspot.com/
---
"Mal" wrote:
> Hey
> I've been doing for SQL for a while but recently I've been trying to get
> some whitepaper for it, I'm now working through some questions I obviously
> first I google the questions before I came here to ask.
> I ran into the questions.
> Give an example of a rowbased statement, and a set based statement. I'm su
re
> know how to code it but I don't know what it is.
> Another question I ran into was "what setting do you ALWAYS disable" in a
> live environment. Now I don't know this either... it's not a registered
> Microsoft exam so I don't know if the questions are dodgy.
> Answers would be appreciated though.
> THanks|||When multiple rows are effected by a query, then that query is a set based
query.
if only one row gets effected by a query, then the query is rowbased.
best Regards,
Chandra
http://chanduas.blogspot.com/
---
"Mal" wrote:
> Hey
> I've been doing for SQL for a while but recently I've been trying to get
> some whitepaper for it, I'm now working through some questions I obviously
> first I google the questions before I came here to ask.
> I ran into the questions.
> Give an example of a rowbased statement, and a set based statement. I'm su
re
> know how to code it but I don't know what it is.
> Another question I ran into was "what setting do you ALWAYS disable" in a
> live environment. Now I don't know this either... it's not a registered
> Microsoft exam so I don't know if the questions are dodgy.
> Answers would be appreciated though.
> THanks|||Hi Mal
For Row by Row operations look at
http://www.sql-server-performance.com/dp_no_cursors.asp
For things to switch off then looks at Brads article:
http://www.sql-server-performance.c...mance_audit.asp
John
"Mal" wrote:
> Hey
> I've been doing for SQL for a while but recently I've been trying to get
> some whitepaper for it, I'm now working through some questions I obviously
> first I google the questions before I came here to ask.
> I ran into the questions.
> Give an example of a rowbased statement, and a set based statement. I'm su
re
> know how to code it but I don't know what it is.
> Another question I ran into was "what setting do you ALWAYS disable" in a
> live environment. Now I don't know this either... it's not a registered
> Microsoft exam so I don't know if the questions are dodgy.
> Answers would be appreciated though.
> THanks|||Chandra,
That was Terrific :(
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Chandra" <Chandra@.discussions.microsoft.com> wrote in message
news:A9EB58C2-F6D2-4244-B324-CF9330F1572A@.microsoft.com...
> Hi Mal
> Row based statement:
> SELECT * FROM <TABLE> WHERE NEWID() = '<some ID>'
>
> SET based statement
> SELECT * FROM <TABLE>
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> ---
>
> "Mal" wrote:
>|||Chandra wrote:
> Hi Mal
> Row based statement:
> SELECT * FROM <TABLE> WHERE NEWID() = '<some ID>'
>
This is not quite correct. SELECT statements generate sets of records (which
is why the term used forthe result of a SELECT statement is "resultset"). A
set can contain a single member.
When we talk about doing a "row by row" operation, we are normally talking
about doing something with a cursor. Looping through a set of rows,
processing one row at a time, is a "row by row" operation. Most experienced
developers frown on row by row processing, due to its usual lack of
performance in comparison to set-based operations.
Here is a set-based operation:
UPDATE <TABLE>
SET <COLUMN> = <value>
WHERE <COLUMN1> = <value1>
Here is the equivalent operation done row by row:
DECLARE @.compare <datatype>
DECLARE cur scroll cursor FOR
SELECT <COLUMN1>, <COLUMN> FROM <TABLE>
FOR UPDATE
open cur
FETCH FIRST FROM cur INTO @.compare
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
if @.@.FETCH_STATUS <> -2
BEGIN
IF @.compare = <value1>
UPDATE <TABLE>
SET <COLUMN> = <value>
WHERE CURRENT OF cur
FETCH NEXT FROM cur INTO @.compare
END
END
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
No comments:
Post a Comment