I am trying to running the below query:
SELECT TOP 1
*, (Title COLLATE utf8_general_ci)
FROM
BibTitles
WHERE
TitlesID > '.$last_iterate_book_id.'
ORDER BY
TitlesID ASC;
in PHP script. The above query is to get data from a SQL Server view.
When I am running the script, it is throwing the below error:
Invalid collation 'utf8_general_ci'
I am using the collation because, my database contains data in different language and showing me those data as question mark (???) instead of actual data. I can't alter the database as well as table due to permission issue.
Please help me with this.
Related
I'm trying to get into SQL using Microsoft SQL Server Management Studio. I've added a database and I want to make a query:
This works and I can execute the code, but after I saved my query and closed the program it doesn't work anymore when I open the program and try to execute the query again. It can't find the terms I'm relating to:
I don't know why this occurs or how I can solve it, it seems that the connection between the query and the database is gone... Can someone help me on this?
You're attempting to execute the query against the master database but that's not where your tables are. Three ways to handle this:
Use the drop-down in the toolbar to switch to the dbArtemis database
Fully-qualify your table names. dbArtemis.dbo.Klantnummer for example
Execute use dbArtemis; in your query window before the query itself.
Just add before your query the name of your database:
USE dbArtemi
GO
SELECT Naam
FROM tblklaten
WHERE klatenummer =
(SELECT DISTINCT klatnummer FROM tblorders where (orderID = 11013));
GO
We are trying to pull data from external source (mssql) to postgres. But when i checked for invoicedate column entries are getting blank at the same time mssql is showing invoicedate values for those entries.
ie
We tried following query on both the DBMS:
When query executed in SQL Server:
select * from tablename where salesorder='168490'
getting 12 rows where invoicedate column is '2015-10-26 00:00:00.000'
But same query is executed on Postgres
select "InvoceDt" from tablename where salesorder='168490'
Getting 12 rows where the column invoicedate is null.
Question is why?
Postgres InvoiceDt column is coming null rather than we can see that SQL Server is showing appropriate data values.
Why is the data different between SQL Server and Postgres for this particular column?
Vicps, you aren't using Postgres and that is why a_horse_with_no_name is having such a hard time trying to understand your question. You are using Pivotal HDB (formally called HAWQ). HAWQ is now associated with the incubator project, "Apache HAWQ" and the commercial version is "Pivotal HDB".
Pivotal HDB is a fork of Pivotal Greenplum database which is a fork of PostgreSQL 8.2. It has many similarities to Postgres but it is most definitely not Postgres.
You are also using Spring-XD to move the data from SQL Server to HDFS which is critical in understanding what the true problem is.
You provided this example:
CREATE TABLE tablename ( "InvoiceDt" timestamp )
LOCATION ('pxf://hostname/path/to/hdfs/?profile=HdfsTextSimple')
FORMAT 'csv' ( delimiter '^' null 'null' quote '~');
Your file only has one column in it? How is this possible? Above, you mention the salesorder column. Secondly, have you tried looking at the file written by Spring-XD?
hdfs dfs -cat hdfs://hostname:8020/path/to/hdfs | grep 168490
I bet you have an extra delimiter, null character, or an escape character in the data which is causing the problem. You also may want to tag your question with spring-xd too.
Recently I found an anomaly with SQL Server database creation. If I create with the sql query
create database 6033SomeDatabase;
It throws an error.
But with the Management Studio UI, I can manually create a database with a name of 6033SomeDatabase.
Is this expected behaviour or is it a bug? Please throw some light on this issue.
Try like this,
IF DB_ID('6033SomeDatabase') IS NULL
CREATE DATABASE [6033SomeDatabase]
I'll try to give you detailed answer.
SQL syntax imposes some restrictions to names of database, tables, and fields. F.e.:
SELECT * FROM SELECT, FROM WHERE SELECT.Id = FROM.SelectId
SQL parser wouldn't parse this query. You should rewrite it:
SELECT * FROM [SELECT], [FROM] WHERE [SELECT].Id = [FROM].SelectId
Another example:
SELECT * FROM T1 WHERE Code = 123e10
Is 123e10 the name of column in T1, or is it a numeric constant for 123×1010? Parser doesn't know.
Therefore, there are rules for naming. If you need some strange database or table name, you can use brackets to enclose it.
I have an Access 2010 FE , with linked tables on SQL Server 2012. I have several queries which are passed through used for the generation of reports.
After migration and recreation of the queries. When I run the reports it throws up the above error.
I did check the permissions and also tried unchecking "Use simple file sharing (recommended).
I have full access for the account which I'm using.
Here are some pass through queries example that I have in my DB,
1.UPDATE TABLE SET TABLE.COLUM=TABLE.COLUMN WHERE CONDITION
2.INSERT INTO TABLE (COL1......) SELECT * FROM TABLE
3.DELETE FROM TABLE
INSERT INTO TABLE (COL1......)
SELECT * FROM TABLE LEFT JOIN ON CONDITION LEFT JOIN CONTIDION WHERE CONDITION
Could you please let me know what settings or changes I need make to correct the above issue.
Thanks in advance , I have moderate knowledge on SQL and MS Access any help is greatly appreciated.
#GordThompson I took your option 1 , started decoding all the queries that are being called in VBA code , I had all my tables linked from SQL Server with return records set to false.
I was able to correct the error , it was a violation of data type where a column with int and float where updating a column with nvarchar , this happened due to not defining them explicitly in the SQL statement.
Thanks for the tips.
Up until today I've been able to run queries without using the [databaseName].[dbo].[fieldName] syntax. And all of a sudden, if I use select * from myTable I get an error for an invalid object. I can't possibly think of something that happened between shutting down my PC yesterday and today. Anyone know anything about this?
Msg 208, Level, 16, State 1 Line 1
Invalid object name 'mytable'
It's only been since today that I have to include the database name in the query. There are no other connections open and no other users of this instance of SQL Server.
I think you mean a query of the form select [fieldName] from [databaseName].[dbo].[mytable]
Here are some possible things to look out for:
Make sure that you are in the correct database context / catalogue (i.e. use [databasename], or select the correct database from the Available Databases drop down in SSMS)
Ensure that if you have a case sensitive collation on your database that the object names in your query match the exact case.
Check that the default schema for your user hasn't changed on this database. Although the default schema is usually [dbo], it can be changed.
Edit : More ideas:
Do SELECT DB_NAME() to see what the current database name is.
Check to see if someone has dropped the table or view entirely, e.g. from the target database, run:
Select * from sysobjects where name = 'myobject'
OR
Select * from sys.tables where name = 'mytable'
OR
Select * from INFORMATION_SCHEMA.TABLES