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)
 Combining 2 SQL statements become 1

Author  Topic 

liangtp@hotmail.com
Starting Member

27 Posts

Posted - 2008-10-05 : 22:35:22
Hi Guys,

I have 2 statements below:

SET @StartDate = (SELECT StartDate FROM tblA WHERE ID = 1)
SET @EndDate = (SELECT EndDate FROM tblA WHERE ID = 1)

Can I combine the two statements to become one statement such as below?

SET @StartDate = StartDate, @EndDate = EndDate FROM tblA WHERE ID = 1
(this one doesn't work)

Thanks.

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-10-05 : 23:40:57
select @StartDate = StartDate, @EndDate = EndDate FROM tblA WHERE ID = 1


elsasoft.org
Go to Top of Page

liangtp@hotmail.com
Starting Member

27 Posts

Posted - 2008-10-05 : 23:56:32
Thanks jezemine. It worked.
Go to Top of Page
   

- Advertisement -