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.
| Author |
Topic |
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2006-07-18 : 23:37:58
|
| HiI could not get this to work.Declare @ColDate as Varchar(15)Select @ColDate = Distinct(TransDate)as TD from tblDemoThanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-19 : 00:02:19
|
"select distinct transdate from tlbdemo" may return multiple records and assigning to a variable will mean you only have the last record in the variable. Is this what you want ? KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-19 : 00:42:29
|
This will assign the only one TransDate to the variable @ColDate eventhough there are several distinct TransDate return.Is this what you want ?Declare @ColDate as Varchar(15)Select Distinct @ColDate = TransDate from tblDemo Or do you want the min or max transdate ?Declare @ColDate as Varchar(15)Select @ColDate = min(TransDate) from tblDemo KH |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2006-07-19 : 01:18:26
|
| Thanks |
 |
|
|
|
|
|