Contents

1 Msg
2 T-SQL
3 願屋


1 Msg #

覃讌 7342, 譴 16, 1, 譴 2
郁屋 覯 "LinkedServerA" OLE DB 螻糾 "MSDASQL" "MSDASQL.login" 蠍一 NULL 螳 覦給. 伎 NULL 給.

2 T-SQL #

declare 
	@sql varchar(8000)

set @sql = '
select 
	login
,	logout
from openquery([LinkedServerA], ''
select 
	login
,	logout
from main.log_' + convert(char(6), getdate()-1, 112) + ''')
WHERE login >= CONVERT(char(8), GETDATE()-1 , 112) 
AND logout < CONVERT(char(8), GETDATE() , 112)
'
exec(@sql)

3 願屋 #

declare 
	@sql varchar(8000)

set @sql = '
select 
	cast(login as datetime) login --讌朱 cast 
,	logout
from openquery([LinkedServerA], ''
select 
	cast(login as char(50)) login --覓語朱 cast 
,	logout
from main.log_' + convert(char(6), getdate()-1, 112) + ''')
WHERE login >= CONVERT(char(8), GETDATE()-1 , 112) 
AND logout < CONVERT(char(8), GETDATE() , 112)
'
exec(@sql)