Get Latitude Longitude from Access to MSSQL - sql-server

I have an Access table with venue information. I'm toying with nearest neighbor stuff to show the website viewer the upcoming event that's nearest to them.
The main, in-house, database is Access but the website pulls the data from MSSQL. What I currently do is maintain the Access database, export the table as Excel 2003, transfer .xls to the web server, delete the table and importing the .xls (within SQL Management Studio).
It is a laborious process and I just realized that, when I import the .xls, I will have to go through and reset all the spatial information (set a primary key, set the data type for lat/lng to geography, give it a spatial index).
Is there a way to automate this process? Is there a way to set the data types and keys during the import process? Obviously, the right thing to do is use MSSQL as the back-end and forgo all the work. Unfortunately, my superiors haven't been receptive to making the change.

I found some information on a page working with basic spatial data that shows you can have lat/lng as separate float fields and/or a POINT(lng,lat) geography field.
With this being said, I could just have a separate lat/lng fields in Access and they should import into MSSQL. By that page, I don't even require a geography field (float will work with some extra code. Assumingly, I should be able to populate the geography field from the float fields with a query.

Related

Select specific tables from an SQL data source in Power BI

I'm working on setting up PowerBI desktop for a client where they'll import 8 specific tables from a database to work on in Power BI.
However, when I go to import the tables, every table in the database is shown and the specific tables must be selected. There are hundreds of tables imported, and a lot of scrolling to select the correct tables, which leaves room for confusion and error for the clients.
The client accesses the database using windows authentication, and I can't change their settings on SSMS as that would affect how they access data on other applications.
I was wondering if there was an simpler way to save a query in Power BI the users can quickly select when setting up a new report.
You could always use raw sql instead:
Or select "empty query" and specify it like so:
Edit: not sure if this is of any help but there's also a filter field:

What would be the best method for building Dynamic Reports from my SQL DB Data?

I am building a simple database with about 6-7 tables. I will be setting a schedule to do a clean import from a .txt file.
I want to take this data and create a report, like I would do in an excel spreadsheet, convert it to a pdf and post it to our company intranet for those interested to access it.
I'm trying to think of the best way to build my report. Would I just use an excel spreadsheet with a direct connection to the database? Would I create some sort of console application (c/c#/vb/vb.net) that would query the db, generate the report in an excel file, convert to pdf and save?
I'm quite comfortable in these different languages, just not as experienced in the reporting services (although I do have a lot of experience working with EXCEL and VBA Macros) but I want to get into it (SSRS) and get familiar with it as I will be doing a lot of projects like this in the future. This is seems like an easy one to get my hands dirty with and learn and build off of.
Any insight or suggestions would be greatly appreciated.
Thanks so much!
My suggestion:
Create desired SQL queries to retrieve the data in desired form
Link these queries to your Excel sheet, perhaps directly in form of pivot tables for aggregation of results
Using VBA, you can easily create PDF from the data at the click of a button
The initial design will be time intensive, but after that, everything is automated and one just needs to press the button that creates the PDF.
How to link Access queries to your Excel file:
Data --> Get external Data
You can easily refresh all data whenever you open the Excelsheet by using the code below in the On Open event of the workbook:
ThisWorkbook.RefreshAll
If you need further clarification, do not hesitate to ask
If your end goal is to create a PDF that will be out on your intranet then I would create the report in SSRS. Then you can schedule it to run and output a PDF to your network location.
I've had good experiences using a pivot table in Excel which is a connected table to your SQL database.
In the connection parameters in Excel there is a field where you can define your SQL query, whether it be to call a stored procedure or just a simple SELECT statement.
The main reason I prefer a pivot table SQL connection rather than a normal table connection is because if you have a chart that references the connected table, the chart formatting will be reset when you refresh your connection (if you need to updated your report).
If I use a chart that references a pivot table (or a pivot chart) then the formatting is retained.

ASP.net MVC - get data from SQL Server without knowing the data-structure

I would like to know how I can get data from SQL Server tables into my ASP.net MVC application without knowing the data-structure in advance.
Example:
a user uploads a .csv file into the application with an unknown data structure (can be 3 fields can be 50 fields with varying data types)
the .csv file gets stored into a SQL Server table
now I want the application to be able to display the data from these uploads in e.g. a HTML table without having to use a hardcoded model
Is it possible to display the data using a connection string and e.g. LINQ to SQL or EF? Best case would be where I can dynamically assign table names etc. into queries.
The models will still be used to access data belonging to the application logic, it's just the displaying of data from user-uploads that is not clear to me at this time.
EF and Linq2Sql will always require you to have a existing model associated to a database table.
If you really need that "dynamic" query, you can use a micro-ORM like dapper.Net to return your query to a dynamic type.
This solution won't save you from having generate the select sql query, by retrieving the list of fields from the table. Maybe you can use the sys tables from sql server (if that is the data base) for that. Like in here

Automatically or easily updating my database

I have available to me a Report that is generated in Microsoft SharePoint, and it holds the quantities for certain items. The reports can be exported as excel documents, but if it is possible i would like to avoid that.
In my Access database I have all the same items but with additional data concerning special requests and item identification in the item's respective documentation folders.
I am looking for a way to have the select few columns that represent the quantities and some other factors, to be automatically updated in my database.
How can I go about this? Is there a specific terminology for what I am attempting to do, I am unable to find it on Google?
So to clarify ... you have item data exported from SharePoint and item data in Access and ideally you'd like to merge both and store the results in Access.
Or maybe another way of putting it, you would like to compliment the data in Access with the data from SharePoint.
If the database that powered the SharePoint report ran in Access as well, the word you are looking for is replication. You want to automatically replicate the data from one server/database to another.
Unfortunately I don't know of any software that replicates data to Access.
Your best bet would be to write a program that scheduled the running of the SharePoint report and then imported that data into Access.
I'm happy to give you the terminology of what to Google for. Just don't make me use SharePoint and Access. :)
If you have the same items in a report in SharePoint and in Access hopefully there is a field that uniquely identifies each item and is used in each table (a unique key). If these items (typically we would say 'records' or 'tuples' in database circles) are inventory SKUs or product numbers would be examples of potential unique keys. If you re taking the information in two tables and merging them together using a unique key we call it a 'Natural Join'. I know Access and SharePoint both support SQL and using SQL this would be done using a SELECT statement.
I would try googling: Natural Join tables in SharePoint and Accesss
Or: SQL SELECT between SharePoint and Access
Hope this helps.
If you choose linked tables to SharePoint (as opposed to importing them local), then you will always have a live copy of the data. In fact this is replicated model in Access 2010. Then a query could be used that joins in the additional table columns with quanity etc. Replication would need caution since any changes to the local access table would go back up to SharePoint and that may not be desired or even allowed.
In this case I would thus simply import the SharePoint tables local and again use a join based on a PK to the tables with quanity etc. that is local. Note that the local copy + cache runs very fast in 2010, and prior to Access 2010 + SharePoint 2010 the speed of such a setup is not so good compared to Access 2010.
If you are using an older version of Access + SharePoint then I would suggest you continue your approach of important the SharePoint tables (as opposed to being linked to the live tables on SharePoint). You then again simply use a query that joins in the additional columns you wish to display in your reports.
Such a results query would not only be of use for reports, but you could export that query into Excel or word.
Best regards.

SQL Server & Mappoint/Spatial Table/Long&Lat

I am trying to map some data out of MS SQL Server 2008 (express) and Mappoint with the Mappoint addin for Sql server. The only issue i have is this spatial table stuff. I think i understand what a spatial data is now but i just need an example of how to go about cross referencing my states table with its spatial data. so i have a table with Vendor names, states they perform work in, type of work they do etc. States listed e.g (Florida, Montana, Puerto Rico, all 50 states) what is going to be their spatial reference. Or can i just add a Long and Lat to the table to reference the states. At this point i am giving up on the whole spatial table or query stuff. Can i just have a long and Lat colum in that table? Would Long&Lat be 2 in 2 different colums on the table?
I do not understand what you are trying to do - can you please restate. Give the overarching question you are trying to solve.
It may be worth moving to full version of SQL Server with its geospatial extensions.
Or do as you suggest use data columns for longitude & latitude. Then you'd drop using the MapPoint add-in completely, and simply use MapPoint's Data Import Wizard. (you may need to create a udl connection to SQL Server).

Resources