Temp table from text file connected via Linked Server
From: CLerner (anonymous_at_discussions.microsoft.com)
Date: 06/24/04
- Next message: Adam Machanic: "Re: Temporary Tables VS - PHYSICAL TABLES"
- Previous message: fred: "real time data in a view."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 24 Jun 2004 10:19:53 -0700
I have a text file as a table in a linked server. I am
able to query on the table as link as the linked server
and text file object names are coded in the select
statement. I am attempting to dynamically build the SQL
statement to query the file, changing the name of the file.
If I run:
SELECT TextFile.*
INTO #TempTextFile
FROM BHOTextFilesCRM...[TA051904_200#TXT] as TextFile
left outer join Imports_TA on
TextFile.Consumer_SSN=Imports_TA.Consumer_SSN
and TextFile.Date_Assess = Imports_TA.Date_Assess
and TextFile.Transmit_Date = Imports_TA.Transmit_Date
WHERE Imports_TA.Consumer_SSN is null
I get the resulting temp file
However, trying to pass a variable for the table name is
not working. Doing the following
DECLARE @strFileName varchar(50)
SET @strFileName = TA051904_200#TXT
SELECT TextFile.*
INTO #TempTextFile
FROM BHOTextFilesCRM...[@strFileName] as TextFile
left outer join Imports_TA on
TextFile.Consumer_SSN=Imports_TA.Consumer_SSN
and TextFile.Date_Assess = Imports_TA.Date_Assess
and TextFile.Transmit_Date = Imports_TA.Transmit_Date
WHERE Imports_TA.Consumer_SSN is null
I get this error:
Server: Msg 7314, Level 16, State 1, Line 25
OLE DB provider 'BHOTextFilesCRM' does not contain
table '@strFileName'. The table either does not exist or
the current user does not have permissions on that table.
What am I missing to get the statement to recognise the
filename when a variable is used? I have tried parsing
the statement into a string and using EXEC. This runs but
the temp table is not available or found.
Thanks,
Cammy
- Next message: Adam Machanic: "Re: Temporary Tables VS - PHYSICAL TABLES"
- Previous message: fred: "real time data in a view."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|