SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 The Yak Corral
 Twit List
 New Topic  Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 88

SwePeso
Patron Saint of Lost Yaks

Sweden
30218 Posts

Posted - 07/08/2011 :  00:42:51  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Help me out explaining the difference between creating vs executing a stored procedure here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=162462



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 07/11/2011 :  08:34:10  Show Profile  Visit Seventhnight's Homepage  Reply with Quote
Celko at it again, though we've seen worse:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=162782

It seems a little ironic that HE is calling the poster rude...

Corey

I Has Returned!!
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 07/12/2011 :  08:11:48  Show Profile  Reply with Quote
I do not understand directions or SQL Server, therefore it is buggy as all get out:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=162507

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

robvolk
Most Valuable Yak

USA
15663 Posts

Posted - 07/12/2011 :  09:34:48  Show Profile  Visit robvolk's Homepage  Reply with Quote
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=162860

Next he'll want a substring of a string without using the...wait for it...SUBSTRING() function.
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 07/12/2011 :  10:41:29  Show Profile  Visit webfred's Homepage  Reply with Quote
Out of a table with 1000000 rows I want to select the customer with id 666 without using a where clause...
If that is too simple then I want it without SELECT...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

robvolk
Most Valuable Yak

USA
15663 Posts

Posted - 07/12/2011 :  11:08:11  Show Profile  Visit robvolk's Homepage  Reply with Quote
C'mon Fred, that's easy:

1. bcp out the entire table
2. use VBScript/Powershell/findstr/sed to extract the row with ID 666
3. use sqlcmd to truncate the table, or create a new one
4. bcp in the single row to the appropriate table

See? No WHERE clause. If you don't want a SELECT, just stop at step 2.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 07/12/2011 :  12:19:45  Show Profile  Reply with Quote
quote:
Originally posted by webfred

Out of a table with 1000000 rows I want to select the customer with id 666 without using a where clause...
If that is too simple then I want it without SELECT...


No, you're never too old to Yak'n'Roll if you're too young to die.


Surely just use ROW_NUMBER on the id (assuming you have one, select the top 666 in a sub select, then order desc and select the top1..
Go to Top of Page

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 07/12/2011 :  13:13:32  Show Profile  Visit Seventhnight's Homepage  Reply with Quote
quote:
Originally posted by RickD

quote:
Originally posted by webfred

Out of a table with 1000000 rows I want to select the customer with id 666 without using a where clause...
If that is too simple then I want it without SELECT...


No, you're never too old to Yak'n'Roll if you're too young to die.


Surely just use ROW_NUMBER on the id (assuming you have one, select the top 666 in a sub select, then order desc and select the top1..



No no no... what if some of the ids below 666 had been deleted??

Select top 1 * From table Order By case when id=666 then 0 else 1 end

Corey

I Has Returned!!
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 07/12/2011 :  13:51:46  Show Profile  Visit webfred's Homepage  Reply with Quote
I love you all - nerds


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30218 Posts

Posted - 07/13/2011 :  01:04:19  Show Profile  Visit SwePeso's Homepage  Reply with Quote
SELECT ID FROM dbo.Table1 GROUP BY ID HAVING ID = 666


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

PSamsig
Constraint Violating Yak Guru

Denmark
384 Posts

Posted - 07/13/2011 :  03:09:07  Show Profile  Send PSamsig a Yahoo! Message  Reply with Quote
UPDATE C SET ID = C.ID
OUTPUT INSERTED.*
FROM dbo.Customer C
INNER JOIN (
   SELECT ID = 666
) D
   ON C.ID = D.ID


-- If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30218 Posts

Posted - 07/13/2011 :  03:48:17  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Replace INNER JOIN content with VALUES(666) and add a column alias for the derived table d, and you get an output for ID 666 without either select nor where.

UPDATE C SET ID = C.ID
OUTPUT INSERTED.*
FROM dbo.Customer C
INNER JOIN (
values(666)
) D(id)
ON C.ID = D.ID



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Sachin.Nand
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 07/13/2011 :  04:17:40  Show Profile  Reply with Quote


Select * From Table1 T1 Inner Join (Select 666 As ID)T On T.ID=T1.ID



PBUH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30218 Posts

Posted - 07/13/2011 :  04:42:47  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Still a SELECT.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Sachin.Nand
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 07/13/2011 :  04:47:33  Show Profile  Reply with Quote
I was referring the initial requirement..The one without the where clause.

PBUH

Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 07/13/2011 :  05:02:52  Show Profile  Reply with Quote
print 666
i cannot take all the credit for this innovative solution. It is based on an original algorithm developed in this thread. http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159217
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 07/13/2011 :  05:13:47  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by sunitabeck

print 666
i cannot take all the credit for this innovative solution. It is based on an original algorithm developed in this thread. http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159217


Sunita, I will have a Beck's on you



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 07/13/2011 :  07:12:16  Show Profile  Reply with Quote
Haha, Fred! You are the inventor of the algorithm, so by all means!!

(I thought you liked Weißbier, if I recall correctly!)
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 07/13/2011 :  07:17:11  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by sunitabeck
(I thought you liked Weißbier, if I recall correctly!)


Oh no, that is a rumor strewn by DonAtWork
And since I know you I like Beck's


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 07/13/2011 :  09:10:01  Show Profile  Reply with Quote
quote:
Originally posted by webfred

quote:
Originally posted by sunitabeck
(I thought you liked Weißbier, if I recall correctly!)


Oh no, that is a rumor strewn by DonAtWork
And since I know you I like Beck's


No, you're never too old to Yak'n'Roll if you're too young to die.


Heh. Fred likes a good Pilsner. He just does not know that Weißbier is the best on the planet.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
Page: of 88 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000