exec master..xp_logevent | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

exec master..xp_logevent

Hi, I’m using the following code in a small sql server 2005 job. Here is the code. declare @code varchar(255)
select @code = (wkstn_id) from dbname.dbo.Wkstn_Status where status_code = ‘7’
if (select count(*)from dbname.dbo.Wkstn_Status
where status_code = ‘7’) > 0
exec master..xp_logevent 50001, @code
It works, but if I have multiple rows in the table with the status_code of 7, it only prints the wkstn_id of one of the rows instead of all of them in the event log. I’m not much of a coder, so I’m not sure how to do this. Any help would be appreciated.
Thanks.
quote:Originally posted by cnikirk Hi, I’m using the following code in a small sql server 2005 job. Here is the code. declare @code varchar(255)
select @code = (wkstn_id) from dbname.dbo.Wkstn_Status where status_code = ‘7’
if (select count(*)from dbname.dbo.Wkstn_Status
where status_code = ‘7’) > 0
exec master..xp_logevent 50001, @code
It works, but if I have multiple rows in the table with the status_code of 7, it only prints the wkstn_id of one of the rows instead of all of them in the event log. I’m not much of a coder, so I’m not sure how to do this. Any help would be appreciated.
Thanks.

You are assigning the value to a local variable that’s why it will only get 1 value assigned. Try using temp table or table variable to get those multiple rows and select from that table. Thanks, Name
———
Dilli Grg (1 row(s) affected)
]]>