Skip to content
Advertisement

Why does this work under Microsoft SQL Server Management Studio but not under R?

I received this SQL statement:

and it runs nicely under MS SSMS. The relevant part of the result is:

When I run it under R I must leave out use MYDATABASE; and be sure I am connected at the right database, which is the case. But the SQL-statement is problematic. The output of:

is data frame with 0 columns and 0 rows.

Is it the use of “temporal tables” (i.e. #mapDT) the cause of the empty data frame? If so, is there a way to get R and/or Python to understand/use them?

Advertisement

Answer

as Gord Thompson knows, the code should include SET NOCOUNT ON;. Thus,

and in my case the row numbers are not wanted, so I also used formals(print.data.frame)$row.names <- FALSE:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement