Get Missing Values from Sql Server using R in sql2016 -
i want find out missing data in table sqlserver.
i write code in rstudio rowcount in each column na values. how convert dataframes columnnames , count both datatable.
the reason want convert dataframe is: in sql2016 when execute sp_execute_eternal_script. expects dataframe output.
below code wrote in rstudio
require(rjdbc) drv <- jdbc("com.microsoft.sqlserver.jdbc.sqlserverdriver","c:/users/vbhattbh/documents/r/sqljdbc_3.0/enu/sqljdbc4.jar") conn <- dbconnect(drv, "jdbc:sqlserver://serveripaddress;instancename=sql2016;databasename=dbname;", "user","pwd") sqltext <- "select * dwh.factpatientimage" queryresults <- dbgetquery(conn, sqltext) colsums(is.na(queryresults)) dbdisconnect(conn)
below code wrote in sql server
exec sp_execute_external_script @language = n'r' ,@script = n'queryresults <-summary(inputdataset); factpatientimage_df <- data.frame(colsums(is.na(queryresults)));' ,@input_data_1 = n'select * dwh.factpatientimage;' , @output_data_1_name = n'factpatientimage_df'
i not getting column names , count while using sql2016 feature of executing r script.
any idea how missing values in each column in sql2016 using r??
Comments
Post a Comment