I have a view in SQL Server named item_movement, now I want to query using Microsoft Query in Excel:
select * from item_movement
But I'm getting this error - why? Is it possible to use Microsoft Query for querying views?
Found out the issue had to use the keyword
use mydbname before query
Related
I need to query PostgreSQL from SQL Server. I created a linked server connection (ODBC for PostgreSQL, the newest). It works on some schemas and not on the others. They're all on the same server.
For example this works:
SELECT * FROM LinkedPS.MyDatabase.Schema1.Table1
and this doesn't:
SELECT * FROM LinkedPS.MyDatabase.Schema2.Table2
I wasn't able to find any property which would cause this.
I am trying implement a paging and sorting repository with a #Query annotation. The query is simple enough:
SELECT DISTINCT(B.batch), B.scanDate, COUNT(B.batchReferenceNumber) as TransactionCount FROM Batch B
My database is SQL Server. The query that is getting generated is:
select
distinct batch0_.BatchNumber as col_0_0_,
count(batch0_.BatchNumber) as col_8_0_
from
BATCH batch0_
order by
batch0_.BatchNumber asc offset ? rows fetch next ? rows only
I get an error: Incorrect syntax near 'offset'.
The reason is "Offset" was not introduced until SQL Server 2012.
Is there any way around this? Or do I need to implement my own repository versus using the interface?
The SQL for the offset/limit clause is generated by your JPA provider.
You might be able to fix this by configuring the correct SqlDialect or if no such dialect is available you may raise an issue with that project.
I have a linked ODBC server (not SQL Server) defined in my SQL Server Management Studio.
The only way I can query it is by using the OPENQUERY command, and that's fine - but it doesn't allow visual query editing or any intellisense.
Is there a way of typing queries against linked servers that behave in the normal way, even an extension?
Try format like this:
<server>.<database>.<schema>.<table>
example:
select foo.id
from databaseserver1.db1.dbo.table1 foo
inner join databaseserver2.db1.dbo.table1 bar
on foo.name = bar.name
You use 3-dot syntax, like this,
<server>.<database>.<schema>.<table>
but it works properly only with linked servers to other instances of MSSQL.
I just upgraded my SSMS to 2008 R2. I'm missing the option to select the top 1000 rows from a table, like this:
Mine looks like this:
I know how to change the number of rows that are displayed, but the options aren't there at all. I saw that someone submitted a bug for this a few years ago, but there was no workaround, and I'm not sure what to do. Any ideas?
EDIT - Azure Problem?
I just used SSMS to open my local SQL Server, and I get the option to select the top 100 rows. But in my other SSMS instance, the one that is connected to my Azure DB, I don't see it. Is it possibly an Azure limitation?
Based on this answer, I believe it is a limitation of SQL Azure. I have not been able to find any additional information that would allow you to work around the issue.
As of 06/04/2015 MS has published a hotfix to solve this issue.
http://support.microsoft.com/en-us/kb/3011055
"An update is available that enables "Select Top 1000 Rows" option for tables and views of SQL Azure database"
You do not have this option in SSMS while working with SQL Azure, you have to exexute the query yourself ... select top 10000 from tablename
There are few other options as well in SSMS which are not displayed in case of SQL Azure.
This is an excpected behaviour for SQL Azure.
It is now available on SqlServer Mgt Studio 2014.
Check that you have correct values in the SQL Server Object Explorer Settings:
I'm using SQL Server 2008 R2. This is my query:
SELECT * FROM sysservers
It works fine when I execute it in SQL Server but when I use the query in VB.net this error comes out:
Invalid object name 'syservers'
You shouldn't be using sysservers anymore - this is a 2000 system table that is only still provided for backward compatibility reasons. You should be using sys.servers and you might want to be explicit about where to find it as well:
SELECT * FROM master.sys.servers;