Skip to contents

Determine SQL Server data types from data frame. Follows SQL Server data type size constraints and chooses the smallest data type size.

Usage

mapDataTypes(x, coltypes)

varChar(x)

varBinary(x)

int(x)

Arguments

x

data.frame object

coltypes

vector with names of columns to override the default data type mapping

Value

character vector with names of columns

Examples


mapDataTypes(data.frame(
  int = 1:5L,
  numeric = seq(0, 1, length.out = 5),
  character = LETTERS[1:5],
  factor = paste(LETTERS[1:5], LETTERS[1:5], sep = ''),
  logical = c(TRUE, FALSE, TRUE, FALSE, TRUE),
  date = seq(Sys.Date() - 4, Sys.Date(), 1L),
  datetime = seq(Sys.time() - 5, Sys.time(), length.out = 5)
  )
)
#>          int      numeric    character       factor      logical         date 
#>    "TINYINT"      "FLOAT" "VARCHAR(1)" "VARCHAR(2)"        "BIT"       "DATE" 
#>     datetime 
#>   "DATETIME"