[R] RODBC problem inserting into tables

Faensen daniel.faensen at web.de
Thu Jan 19 18:42:15 CET 2012


I have a problem with RODBC statements that seems to be related to inserting
data into a table during an SQL batch (MS SQL Server). It started from a
stored procedure that didn't return data to R but I could boil it down to
the following simplified code snippets.

The first one does work:
sqlQuery(channel, "
	CREATE TABLE tab (x int)
	
	SELECT 'Test' AS Name
		
	INSERT INTO tab(x)
	VALUES(0)

	DROP TABLE tab
")

But running the SELECT statement after the INSERT statement does not:
sqlQuery(channel, "
	CREATE TABLE tab (x int)
	
	INSERT INTO tab(x)
	VALUES(0)

	SELECT 'Test' AS Name
		
	DROP TABLE tab
")

The table is not even used in the SELECT statement (of course, in my real
code it is).

I would appreciate any help

Daniel



--
View this message in context: http://r.789695.n4.nabble.com/RODBC-problem-inserting-into-tables-tp4310772p4310772.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list