My Excel 2016 doesn't have the DSN drop down list when creating a New Query to connect to an ODBC data source. It only shows the connection string option. How can I get it to show the option highlighted in the second image?
Related
I am new to using SQL Server from RStudio. I am connected to SQL Server from RStudio and the server has several different projects listed in the below image. For this work I am using odbc library. I am trying to retrieve the tables of a specific project(Project_3960). I have tried dbListTables(conn,"Project_3960") but this command retrieve the tables from all the projects listed in the below Picture. I just want to retrieve the table which are listed in dbo in Project_3690.
The first picture is from RStudio and the second picture is from SQL Management Studio to show the structure of the folders, in case for executing SQL Query.
Thanks
Click on the arrow to the left of the dbo object under Project_3690, and it should show you the tables you have access to. If it does not, then you have a permissions problem and will need to talk with the DBA. That allows you to see them via the GUI. In fact, if you don't already know the names of the tables you should be accessing (such as to follow my code below), then this is the easiest, as they are already filtering out the system and other tables that obscure what you need.
To see them in R code, then dbListTables(conn) will show you all tables, including the ones in the Connections pane I just described but also a lot of system and otherwise-internal tables that you don't need. On my SQL Server instance, it returns over 600 tables, so ... you may not want to do just that, but you can look for specific tables.
For example, if you know you should have tables Table_A and Table_B, then you could do
alltables <- dbListTables(conn)
grep("table_", alltables, value = TRUE, ignore.case = TRUE)
to see all of the table names with that string in its name.
If you do not see tables that you know you need to access, then it is likely that your connection code did not include the specific database, in which case you need something like:
conn <- dbConnect(odbc(), database="Project_3690", uid="...", pwd="...",
server="...", driver = "...")
(Most fields should already be in your connection code, don't use literal ... for your strings.)
One can use a system table to find the other tables:
DBI::dbGetQuery(conn, "select * from information_schema.tables where table_type = 'BASE TABLE' and table_schema = 'dbo'")
# TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
# 1 Project_3690 dbo Table_A BASE TABLE
# 2 Project_3690 dbo Table_B BASE TABLE
# 3 Project_3690 dbo Table_C BASE TABLE
(Notional output but representative of what it should look like.)
Its not quite direct to retrieve the data from SQL server using RStudio when you have different schemas and all are connected to the server. It is easy to view the connected Databases with schema in SQL Server Management Studio but not in RStudio. The easiest way while using Rodbc is to use dot(.) operator and its easy to retrieve the tables of a specific data base is by using "." with dbGetQuery function. I tried dbGetQuery(conn, "select * from project_3690.dbo.AE_ISD ") and it works perfectly fine.
I have connect Microsoft SQL Server 15 on Windows with a DSN name and i can see this connection in the connection window in Rstudio as the picture shows
But i want to take a specific table from this database AdventureWorks2019 -> Sales -> CreditCard for example ?
What command should i use in order to appear this table as a data frame or tibble in R and play with this data frame ?
I can what the table includes in the view script as you can see.
You have to write a SQL Query and execute it.
You can use the odbc::dbGetQuery() function.
Try this code :
my_dataframe <- odbc::dbGetQuery(conn = con, "SELECT TOP 1000 * FROM Sales.CreditCard")
Teradata Studio Express, Version 16.2
I queried from an oracle database using TSE's SQL file editor (Since it is a non-TeraData database or else I would be using TSE's Teradata SQL editor). When querying from SQL File Editor, TSE provides the result within the SQL Results panel.
What I want to do is to export the result to an excel file but it does
not provide an option to do so. How do I approach this?
Below is a screenshot comparing result set panels. The left panel (querying from Teradata SQL Editor) has an option to export to excel but the right panel (Querying SQL File Editor) does not.
Finally figured it out.. Don't know why they don't provide a export option icon yet but here is solution:
Right click on the result table.
It will provides options. Select Export, then Current Result...
Then this window will appear (save it as a csv file and you should be able to open with Excel):
I am creating an application which will upload data from Excel to SQL Server using ASP.NET. I know how to upload Excel data using SqlBulkCopy. But I am trying to upload some extra data for the table column (addeddate, addedby...etc) which is not present in the Excel sheet.
I get this error:
The given ColumnName '18-01-2016 17:24:07' does not match up with any column in data source.
You can try below solution to insert constant values like addeddate, addedby...etc.
SELECT
EXCEL_COL1,
EXCEL_COL2,
'newconstantvalue' as CustomCol
FROM
ExcelSheet1
Then
bulkCopy.ColumnMappings.Add("Table_COL3", "CustomCol");
Please refer the article for more detail.
I have created a report file in my ASP application, Statistics.rdlc
I have created a Data Source which connects to my local database.
I now wish to add a Dataset using a specific query I have written, however when I right click Datasets in the Report Data panel and select my Data source I am presented with a list of the tables on the database under 'Available datasets'.
What I am expecting to see here is the Dataset1.xsd I created which contains the following:
That Query contains the SQL I wish to apply to my report table, can any point out what im doing wrong here?
I needed to create a table adapter not a query.
This post helped me out:
http://www.c-sharpcorner.com/UploadFile/a72401/rdlc-report-generation-using-dataset/
Sometimes report view doens't allow when you use "SELECT * FROM". Put all columns instead of *.
Ex: SELECT column1, column2, column3 FROM table