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 |
|
reacha
Starting Member
49 Posts |
Posted - 2010-10-11 : 12:05:43
|
| i have a query like thisselect @res = select top(1) (CONVERT(varchar(30), eventid, 113))+''+ '@'+''+ convert(varchar(30),AUDIT.Auditstamp,113) from auditwhere AUDIT.pkgid = 9288283and AUDIT.audittype = 7and queueid <> -1order by AUDIT.auditstamp descThe output of this query is31@23 Aug 2010 18:58:38:307Now i need to separate the resultas getting the value before @ into one variableand after the @ value into another variablePlease help me out!!Thanks,reacha |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-11 : 12:14:07
|
| [code]select top 1 @res = (CONVERT(varchar(30), eventid, 113)), @otherVar = convert(varchar(30),AUDIT.Auditstamp,113)from auditwhere AUDIT.pkgid = 9288283and AUDIT.audittype = 7and queueid <> -1order by AUDIT.auditstamp desc[/code]actually, don't need to convert 'em since no need to concatenate this way |
 |
|
|
reacha
Starting Member
49 Posts |
Posted - 2010-10-11 : 12:20:57
|
| Select @AuditstampQueueEntered = select top(1)(AUDIT.auditstamp),@QueueEventID= (dbo.AUDIT.eventid )from auditwhere AUDIT.pkgid = @pkgidand AUDIT.audittype = 7and queueid <> -1order by AUDIT.auditstamp desc)I am getting the error message asMsg 156, Level 15, State 1, Procedure msp_EventIDAuditStampQueueEntered, Line 15Incorrect syntax near the keyword 'select'.Msg 141, Level 15, State 1, Procedure msp_EventIDAuditStampQueueEntered, Line 15A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-11 : 12:29:23
|
| [code]Select top 1 @AuditstampQueueEntered = AUDIT.auditstamp,@QueueEventID= dbo.AUDIT.eventidfrom auditwhere AUDIT.pkgid = @pkgidand AUDIT.audittype = 7and queueid <> -1order by AUDIT.auditstamp desc[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|