MakeSQLTempTable: Create a Microsoft SQL Server temporary table

View source: R/MakeSQLTempTable.R

MakeSQLTempTableR Documentation

Create a Microsoft SQL Server temporary table

Description

Copy an R data frame into Microsoft SQL Server as a temporary table which can then be used to query other SQL tables

Usage

MakeSQLTempTable(chan, data, tbl_name, columns, dtypes)

Arguments

chan

the ODBC channel

data

the data frame to copy to SQL

tbl_name

the desired temporary table name, without the pound sign passed as a string

columns

the columns from data wished to be copied. To be passed as a vector of strings.

dtypes

the data types of those columns. Also to be passed as a vector of strings.

Examples

library(RODBC)

chan <- odbcConnect("AthensSql")
# if pulling data from Bedmaster, all dates should be unix epochs, which is just an integer.
MakeSQLTempTable(chan, data, tbl_name="patients", columns=c("MRN", "Test_Date"), dtypes=c("integer", "integer"))

kwdoyle/kevtools documentation built on Jan. 4, 2023, 10:32 p.m.