I have a need to pull data from multiple Excel books with multiple spreadsheets. I'm using a cursor to walk through each one, but I can't seem to get my syntax straight for the actual SELECT inside. The following code, where "@thestate" is my variable (AK, AL, AZ, etc.) does this:INSERT INTO dbo.bck_county (county, state_id)SELECT dbo.fn_cap_words(county) 'county', stateFROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=C:\SQL\1.xls;Extended Properties=Excel 8.0')...@thestateWHERE county IS NOT NULLGROUP BY state, countyServer: Msg 170, Level 15, State 1, Line 25Line 25: Incorrect syntax near '@thestate'.So I thought I'd throw everything into a string and just EXEC the string. Again, trouble with my syntax. (code below wrapped for aesthetics/page width. SET @tempstring is all on a single line)SET @tempstring = N'INSERT INTO dbo.bck_county (county, state_id)SELECT dbo.fn_cap_words(county) ''county'', stateFROM OPENDATASOURCE(''Microsoft.Jet.OLEDB.4.0'',''Data Source=C:\SQL\1.xls;Extended Properties=Excel 8.0'')...[' + @thestate + '$]WHERE county IS NOT NULL GROUP BY state, county'EXEC (@tempstring)Server: Msg 105, Level 15, State 1, Line 1Unclosed quotation mark before the character string 'Microsoft.Jet'.Any help with my syntax would be appreciated.-Brian"Pray, 'prA, from Latin precari, from prec-, prex; verb:. To ask that the laws of the universe be annulled in behalf of a single petitioner confessedly unworthy." - Ambrose Bierce (1842-1914)