Lesson 3 for MSDN error SQL Server Data Tools - tsql

i'm currently following this link and performing the steps
https://msdn.microsoft.com/en-us/library/ms170625.aspx
however, after importing in the Transact-SQL query, it tells me that
"Could not create a list of fields for the query. Verify that you connect to the data source and that your query syntax is correct. Query (7,24) Parser: The syntax for 'sp' is incorrect"
What could be the problem? I have tested connection of the database and it is connected. (and yes, the table exists in the database)

Related

An error occurred while creating datasets: (table_name) Table could not be found for mixpanel data in redshift

new to superset here. I'm connecting mixpanel data (stored in redshift) to superset, but I do not see tables available when I 'add dataset' in superset. Specifically, I want to connect to mp_master_event, and I wonder if the reason it does not show is because it's stored under "External Tables?"
When I type mp_master_event in the 'table' field, I get this error: An error occurred while creating datasets: (table_name) Table [mp_master_event] could not be found, please double check your database connection, schema, and table name. The database connection is fine and the schema 'mixpanel' I've chosen is right.
Any ideas what I should do?

SQL Developer and DB2 errors

I'd like to use SQL Developer with DB2, I was able to connect and I canned execute my queries, but when I have an error, I cannot know witch error is. SQL Developer shown me only the error code, not the message. There is the way to know the error I have?
EDIT:
For example, launching this query:
Select * from WrongTable
other programs says:
ERROR[42704][IBM][DB2/NT64] SQL0204N "USERNAME.WRONGTABLE" รจ un nome non definito
sqldeveloper limits its report to the error nr only:
Errore alla riga del comando : 1 colonna : 1
Report errori -
Errore SQL: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=USERNAME.WRONGTABLE, DRIVER=4.19.49
Thank you.
The URL syntax for connecting to Db2 with type-4 jdbc drivers is documented here.
The property that controls how much information is returned with getMessage() is called retrieveMessagesFromServerOnGetMessage, and its default value is disabled ( false , 0 ). Set it to value 1 (or YES, or true )to enable more details on errors.
You can append many properties after the database name in the Database field, on the Oracle SQL-Developer connection properties. Express each property in the form x=y , each x=y pair is separated by a semi-colon and the final one is terminated by a semi-colon, and the first property is prefixed by colon immediately after the database name.
For example, suppose the database name is sample and I wanted three additional properties, the I would put this in the Database field in Oracle-SQL-developer:
sample:useJDBC4ColumnNameAndLabelSemantics=No;securityMechanism=11;retrieveMessagesFromServerOnGetMessage=1;
If value 1 does not give the expected result, use value YES although they should be equivalent. Remember to SAVE the setting change, disconnect from the database, reconnect , before retrying your queries to assess the change.
Many other properties are available, see many related pages in the documentation , some properties are common to all target Db2 platforms, other properties are specific to Db2-LUW, or Db2-Z/OS, or Informix etc, so read the docs carefully. Some properties can be set by code after the connection is already established.

MySQLi Update data in a table

Please help me out with this. Basically to update an existing table (chem_users) with data using 2 keys UserId & Password (or only 1 primary key is allowed?).
Using MySQLi, what is wrong with this syntax.
$sql = "UPDATE chem_users SET (Prj1, Prj2) VALUES ('{$_POST['kinetics']}',
'{$_POST['thermo']}') WHERE (UserId=JohnKing Password=1234rewq)";
I got this error:
Error saving user data You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(Prj1, Prj2) VALUES ('kinetics' at line 1
Try using this syntax:
$sql="UPDATE `chem_users` SET `Prj1`=".$_POST['kinetics'].",`Prj2`=".$_POST['thermo']." WHERE `UserId`='JohnKing' AND `Password`='1234rewq'";
By the way, you shouldn't just concatenate a variable inside a query like you are doing,you should use Prepared Statements.You can learn a little bit about it in this link: http://www.w3schools.com/php/php_mysql_prepared_statements.asp

JPA: How to call a stored procedure

I have a stored procedure in my project under sql/my_prod.sql
there I have my function delete_entity
In my entity
#NamedNativeQuery(name = "delete_entity_prod",
query = "{call /sql/delete_entity(:lineId)}",
and I call it
Query query = entityManager.createNamedQuery("delete_entity_prod")
setParameter("lineId",lineId);
I followed this example: http://objectopia.com/2009/06/26/calling-stored-procedures-in-jpa/
but it does not execute the delete and it does not send any error.
I haven't found clear information about this, am I missing something? Maybe I need to load the my_prod.sql first? But how?
JPA 2.1 standardized stored procedure support if you are able to use it, with examples here http://en.wikibooks.org/wiki/Java_Persistence/Advanced_Topics#Stored_Procedures
This is actually they way you create a query.
Query query = entityManager.createNamedQuery("delete_entity_prod")
setParameter("lineId",lineId);
To call it you must execute:
query.executeUpdate();
Of course, the DB must already contain the procedure. So if you have it defined in your SQL file, have a look at Executing SQL Statements from a Text File(this is for MySQL but other database systems use a similar approach to execute scripts)
There is no error shown because query is not executed at any point - just instance of Query is created. Query can be executed by calling executeUpdate:
query.executeUpdate();
Then next problem will arise: Writing some stored procedures to file is not enough - procedures live in database, not in files. So next thing to do is to check that there is correct script to create stored procedure in hands (maybe that is currently content of sql/my_prod.sql) and then use that to create procedure via database client.
All JPA implementations do not support calling stored procedures, but I assume Hibernate is used under the hood, because that is also used in linked tutorial.
It can be the case that current
{call /sql/delete_entity(:lineId)}
is right syntax for calling stored procedure in your database. It looks rather suspicious because of /sql/. If it turns out that this is incorrect syntax, then:
Consult manual for correct syntax
Test via client
Use that as a value of query attribute in NamedNativeQuery annotation.
All that with combination MySQL+Hibernate is explained for example here.

T-SQL 2000: Four part table name

I don't usually work with linked servers, and so I'm not sure what I'm doing wrong here.
A query like this will work to a linked foxpro server from sql 2000:
EXEC('Select * from openquery(linkedServer, ''select * from linkedTable'')')
However, from researching on the internet, something like this should also work:
Select * from linkedserver...linkedtable
but I receive this error:
Server: Msg 7313, Level 16, State 1, Line 1
Invalid schema or catalog specified for provider 'MSDASQL'.
OLE DB error trace [Non-interface error: Invalid schema or catalog specified for the provider.].
I realize it's supposed to be ServerAlias.Category.Schema.TableName, but if I run sp_ tables _ex on the linked server, for the category for all tables I just get the network path to where the data files are, and the schema is null.
Is this server setup incorrectly? Or is what I'm trying to do not possible?
From MSDN:
Always use fully qualified names when
working with objects on linked
servers. There is no support for
implicit resolution to the dbo owner
name for tables in linked servers
You cannot rely on the implicit schema name resolution of the '..' notation for linked servers. For a FoxPro 'server' you're going to have to use the database and schema as they map to their FoxPro counterparts in the driver you use (I think they map to folder and file name, but I have't use a ISAM file driver in more than 10 years now).
I think you need to be explicit about resources in the linked server part of the query, for example:
EXEC SomeLinkedServer.Database.dbo.SomeStoredProc
In other words just dotting them out doesn't work in this case, you have to be more specific.
It's actually:
ServerAlias.Catalog.Schema.LinkedTable
Catalog is the database that you're querying on the linked server, and catalog is the catalog of the remote table. So a valid four-part name would look lik this
ServerAlias.AdventureWorks.HumanResources.Employee
or
ServerAlias.MyDB.dbo.MyTable