Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL puzzles 4

Status
Not open for further replies.

SQLDenis

Programmer
Oct 1, 2005
5,575
0
0
US
What if we come up with some SQL puzzles/problems
One of us posts one every Friday and we have by Monday to give answers. The best answer(s) gets stars
This is a good way to improve SQL skills (and learn new tricks) and get away from the TV during those log winter nights

Just an idea let me know what you think



Denis The SQL Menace
SQL blog:
Personal Blog:
 
Absolutely.

And we don't have to ask ESquared for opinion [smile].

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
I'm in.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Let's make some simple rules first... nothing strict.

For example: SQL2000, 2k5 or both?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 

We may want see more answers for a puzzle or a business question, so I guess we like both ss2k and ss2k5 allowed.
 
To get you started (and since it is friday), here was a nice one from DBForums a while back:

What function returns 0, if called first thing after connecting to SQL Server, but never returns 0 after that initial call.

I am not sure who the credit goes to, as the original thread has apparently been lost in one of DBForums' several "DB problems".
 
@@IDLE?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
More likely... @@IDLE is global (after server starts), not per-connection.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
sp_SetAppRole

BOL said:
Return Code Values
0 (success) and 1 (failure)

After an application role is activated with sp_setapprole, the role cannot be deactivated in the current database until the user disconnects from SQL Server.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
This is sproc, not a function... :(

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Rule: if you use a question you find elsewhere, CREDIT must be given to the originator. Yelworcm did this by creditting DBForums (would have been nice to give credit to the actual originator, but that's not always possible).

I think the questions should be from both 2000 and 2005. Those that don't have 2005 can download the 2005 BOL and participate and learn something new.

Rule: If a question is specific to a version, that should be stated at the beginning. ie...
SQL Server 2005
Question..........

-SQLBill

Posting advice: FAQ481-4875
 
Ok I have one for you people hehehe
First person who answers the 2 part question will get a star
I used to ask this when interviewing people and nobody knew the answer
So here we go
This is only for SQL Server 2000 so the answer can not be SNAPSHOT ISOLATION
It's a 2 part question
1) besides read commited, read uncommited, repeatable read and serializable what is the 5th isolation level available in SQL Server 2000
2) Where would you use it

Remember both parts of the question have to be answered for the star

Have fun, btw this is documented so you should be able to find it


Denis The SQL Menace
SQL blog:
Personal Blog:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top