I've created a new table in SQL Server Management Studio, which includes a Geography column.
Now, I'm trying to enter data in this column using the SSMS UI, but I just can't find the right way of doing it.
So, how can that be done?
I wouldn't think SSMS natively supports doing this with a nice interface (e.g. a map). Maybe there's some add-on to allow this, or likely some 3rd party app.
If you're happy with doing it in SQL, try this:
UPDATE tableName SET geographyColumn = geography::Point(47.65100, -122.34900, 4326)
Derived from here.
Here are 4 more ways to do the same.
If editing a table cell a la mano just type in
POINT (2.434548 48.858319 4326)
Related
I am trying to export a datatable from Microsoft Access 2016 via ODBC Export to a MariaDB. I have tried:
do a right click on the datatable and choose "Export" --> "ODBC-Database"
then choose the preconfigured ODBC User-DSN
Then I get the ODBC-Call Error:
"ODBC-Driver[...] Data truncated for column 'TotRev' at row 1 [#1265]"
I have tried different codings, as I got other error codes before which were related to that.
I would really appreciate a hint for this solution. The used Database is MariaDB with utf8-mb4 encoding.
Having no familiarity at all with MariaDB - my only suggestion is to export out of Access to a neutral format; either text file or excel.
Then on the MariaDB side - import the neutral file.
I have solved the problem: One specific characteristic with Access is that there exists a datatype currency. This is the problem and so the question is how to get rid of it. Just changing the datatype did not work, as Access run out of memory. The reason is, that Access tries to keep both tables (old datatype + new datatype) in memory.
To solve this problem I found a nice explanation on Microsoft pages. What I did is to follow the hint on this page:
Microsoft forum entry by John W. Vinson/MVP
Here his advice:
"[...]An alternative way to accomplish this task requires a couple of steps but works with any size table:
Rename the table to tablename_old
Copy and paste it to tablename, using the option design mode only
Change the datatype in the new empty table
Run an Append query to migrate the data
It may be necessary to drop and reestablish relationships.[...]"
As I am not familiar with Access here the link to office support how to append an query
Add records to a table by using an append query
My current application was built up in SQL Server 2008 server in JAVA with Hibernate and I had used HierarchyId data type for department hierarchy in my database.
I had written SQL queries to deal with HierarchyId datatype. And I also have n-Level of department tree structure.
Now I want to change my Database server from SQL Server 2008 to MySQL as per business requirement.
After feasibility checking I came with the solution that my whole application will migrate to MySQL database server except HierarchyId data type.
So my main challenge is to find alternate solution of HierarchyId data type with the minimal change in coding.
What is the best way to implement department hierarchy in my database?
Thanks...
I faced the similar situation when our team decided to migrate from MS-SQL to MySQL. We resolved the issue using the following steps:
Added a column of type varchar(100) to the same table in MS SQL.
Converted the hierarchyid from hexadecimal value to string using the hierarchyid.ToString() function as saved it in the newly created column using computed column functionality. for eg. 0x58 -> "/1/", 0x7CE0 -> "/3/7/".
The level of the entity is equal to no-of '/''s minus 1.
These columns could be migrated to the MySQL.
The IsDesendantOf() and is method was replaced with LIKE function of string concaenated with '%'.
Thus we got rid of the hierarchyid functionality in MySQL.
Whenever we face such an issue, we just need to ask ourselves, what would we have done if this functionality would not have been provided by the tool we use. We generally end up getting the answer optimally.
Mysql has no equivalent that I'm aware of, but you could store the same data in a varchar.
For operations involving the HierarchyId, you're probably going to have to implement them yourself, probably as either user defined functions or stored procedures.
What sqlserver does looks like the "materialized path" method of storing a hierarchy. One example of that in mysql can be seen at http://www.cloudconnected.fr/2009/05/26/trees-in-sql-an-approach-based-on-materialized-paths-and-normalization-for-mysql/
I have to pull data from Oracle's "A-Table" on daily basis and insert the same to Ax "A-Table".
Can anyone please tell me how can I achieve the same.
Thanks
You need to download the Oracle drivers for Windows ( http://www.oracle.com/technetwork/developer-tools/visual-studio/downloads/index.html ).
Then take a look at this http://floditt.blogspot.mx/2011/08/using-adonet-with-x.html. Instead of using System.Data.SqlClient data types you have to use the oracle classes (System.Data.OracleClient.OracleConnection, OracleCommand, OracleReader, etc...) which you have installed previously.
If you want it to be run everyday just set a new batch job (in Base -> Inquiries -> Batch job).
I have a table with:
vegetable name -- calcium contents -- Potassium contents -- vitamins -- fibers-- price (etc)
Let's say there are 5 entries (rows) in the table and I have to initially feed the data manually, like a first one time data feeding.
My requirement/problem is:
On a GUI when I select a vegetable name from a drop down menu I should get the contents displayed and then all of them should get added to get final score except the 'price'.
On the GUI if I select the 'vegetable name' and any one of the other 'property' (like 'fibers') then only that value should be displayed. e.g query-- spinach, fiber ? answer spinach-fiber = 20 unit., or spinach-vitamins = 40units etc.
I also want help in what type of database I should use here and how to populate the data for accessing it in the program later on. I believe its a simple data table of small size so what is the most efficient way of doing this?
Specific help with code will be of great help as I am absolutely new to java and netbeans.
Also, can I have a separate GUI for adding/appending further data from user in the same table? If yes, how is it done please?
I am using Netbeans 7.1.2.
After some search I got info about MySQL datatables in netbeans. (http://netbeans.org/kb/docs/ide/java-db.html)
I have created and made entries in the table but do not know how to access them for my questions 1 and 2 above. Also not sure if it is the right data table that I should be using for such simple use.
Seems like you need to learn about JDBC first. Just to clarify connecting to a database inside the IDE is generally used for more development/administrative type duties and you WONT be using it in your Swing program.
So for example you need to load a set of test data to test a function you would typically use either the MySQL workbench or load it via the IDE. However you will not connect this way when you run a program.
What you need to learn is how to connect to a database from a front end, how to execute a query and how to display the query. At this point I would suggest getting a couple of books on JDBC or even doing a google search for JDBC introduction tutorials.
Get to learn JDBC without thinking too much about the front end. Do a couple of examples and then once you are familiar with JDBC then work on the front end.
You might want to spend time on learning basic SQL as well as this will be needed to properly query your database. I am assuming you have not done any SQL.
Here is a reasonably good link to a site with information that you might want to use http://infolab.stanford.edu/~ullman/fcdb/oracle/or-jdbc.html
Just remember the IDE(Netbeans) basically uses JDBC to allow you to connect and manipulate data. So while it is based on JDBC the IDE database explorer is NOT the tool you will be using when programming your swing interface.
I have a SQL Server 2008 db. It contains some great test data...a proposal that has a lot of child records. I want to script this Proposal so as not to re-enter the data for each new environment. Is there a way to script the data in the proposal as well as all the dependent tables. I can run a query to get the data but what I really need is a set of SQL Insert Statements to insert the data into the new environments. At least that's what I think I need. Any ideas?
Several options for this exist.
If you're a DIY person and want a manual option with no support, check out Vyas' script:
http://vyaskn.tripod.com/code.htm#inserts
CodeProject article:
http://www.codeproject.com/Articles/5598/Generating-INSERT-statements-in-SQL-Server
Red Gate SQL Compare (to build the schema in the destination) and Data Compare (to pump data over there after the tables are created):
http://www.red-gate.com/products/sql-development/sql-compare/
SSMS Tools Pack:
http://ssmstoolspack.com/Features
If you dont want to use 3rd party stuff, you can pretty much achieve this with SSMS out of the box, simply right click the database, hit "Generate Scripts", follow the wizard, on the options step, set "Script Data" to true (or, if your using 2012, set "Types of data to script" to "Schema and Data").
http://msdn.microsoft.com/en-us/library/ms178078.aspx
http://msdn.microsoft.com/en-us/library/ee210523.aspx