Ah ok,
What this means is that the sections of the query that are sub queries, see below in yellow.
SELECT (select right(s, len(s) - charindex(' ',s)) from #a where s like 'serverid%') as ServerID,
(select right(s, len(s) - charindex(' ',s)) from #a where s like 'Last log on%') as LastLogOn,
(select right(s, len(s) - charindex(' ',s)) from #a where s like 'Linkstatus%') as LinkStatus
these are returning multiple values, which if there was only one server log in the file they would be fine, but because there are multiples it means the select statement cannot compile correctly.
So some questions for you,
Does the file always get built like the following
Serverid: 3
Last log on : 13/23/2007
Linkstatus: Good
Serverid: 4
Last log on : 23/23/2007
Linkstatus: Good
Serverid: 5
Last log on : 03/23/2007
Linkstatus: Worse
Is there ever a case where the file could be in a different format
e.g.
Last log on : 13/23/2007
Serverid: 3
Linkstatus: Good
Last log on : 23/23/2007
Serverid: 4
Linkstatus: Good
Last log on : 03/23/2007
Serverid: 5
Linkstatus: Worse
I'm asking these questions now as I believe we could use a Cursor to resolve your issue. I won't have time to put together something until tonight as I am at work right now. but the pseudo code is below.
Basically if the file is always done in that way you could use a cursor to loop through the temporary table three rows at a time, with each loop you would set one of the relevant variables,
So the following pseudo code would be the
CREATE
TABLE #a(s nvarchar(100))
bulk
insert #a from 'c:\serverlog.txt'
Declare Cursor
Open Cursor with Select * From #a
Declare serverID, lastLogon, Status
Declare @Count INT
SET @Count = 0
While @@FetchStatus <> -1
IF @Count = 1
Set Server ID Variable
Select @Count = @Count + 1
if @Count = 2
Set Last Logon Variable
Select @Count = @Count + 1
if @Count = 3
Set Link Status Variable
Insert Record into Table using all three variables
Set the Variables to be null
SELECT @Count = 0
Move to next row
Close Cursor
Deallocate cursor
drop table #a
Forgive me I can't think of the correct cursor syntax but if you press F1 in sql management studio then lookup cursors you will find a lot of help on them in there, when I get home in 4 hrs time i'll do it properly, unless you post and say you've got there on your own.
The close and deallocate cursor statements are important if you know .Net programming they are basically the equivalent of Dispose Methods, they cleanup the cursors resources.
Hope this helps
Pete