Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How To getData Without using Select Statement

Author  Topic 

Suni
Starting Member

3 Posts

Posted - 2008-06-24 : 04:11:32
Hi,

In one of the interview recently i faced below question. please answer this

I want to select all the data from Employees Without using Select Keyword.

like "select * from Employees". without using select keyword
i need to fetch all records from Employees. How do i do this

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-24 : 04:14:10
quote:
i need to fetch all records from Employees. How do i do this

use dOg's keyword


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-24 : 04:17:17
[code]DELETE e
OUTPUT *
FROM Employees AS e

UPDATE e
SET e.EmpName = e.EmpName
OUTPUT *
FROM Employees AS e[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-24 : 04:18:16
quote:
Originally posted by Peso

DELETE     e
OUTPUT *
FROM Employees AS e

UPDATE e
SET e.EmpName = e.EmpName
OUTPUT *
FROM Employees AS e



E 12°55'05.25"
N 56°04'39.16"




I think i prefer the 1st query


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Suni
Starting Member

3 Posts

Posted - 2008-06-24 : 04:29:55
If i use any of the above queries i am getting error as follows

Incorrect syntax near '*'.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-24 : 04:36:53
[code]
UPDATE e
SET e.EmpName = e.EmpName
OUTPUT inserted.*
FROM Employees AS e
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Suni
Starting Member

3 Posts

Posted - 2008-06-24 : 05:31:09
Will this query works for normal table.
i mean will this query works only on Inserted,deleted,updated tables?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-24 : 05:54:52
quote:
Originally posted by Suni

Will this query works for normal table.
i mean will this query works only on Inserted,deleted,updated tables?


they are just internal tables containing value from your table which an action like insert,delete etc is performed on your table.so its same data in your table that is retrived.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-24 : 09:17:08
quote:
Originally posted by Suni

Hi,

In one of the interview recently i faced below question. please answer this

I want to select all the data from Employees Without using Select Keyword.

like "select * from Employees". without using select keyword
i need to fetch all records from Employees. How do i do this


Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -