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.
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.
The following query has a red squiggly underlining for the server through to the table this bit [OtherServer].[UAT_DB].[dbo].[profileTable] and when hovering says Invalid Object Name, but interestingly if I execute the line it returns the correct records from the linked server table:-
select * from [OtherServer].[UAT_DB].[dbo].[profileTable]
Intellisense in sql server works fine for queries on the same server. But when it comes to run a query on a remote server then it doesn't really know how to deal with it.
For certainty intellisense will not work with a remote server that has a version that does not support intellisense. For instance if the remote database has a compatibility level of 80(SQL 2000).
Refreshing the local intellisense cache might fix it.
Whilst in a query window, either:
Press Ctrl + Shift + R
Go to the Edit menu -> Intellisense -> Refresh Local Cache
I had to use an ALIAS in order for it to work.
Example:
select * from [OtherServer].[UAT_DB].[dbo].[profileTable] myalias
where myalias.profileid = 1
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:
Is there some kind of plug in you can get for Microsoft SQL management studio that will:
1) help you format your sql (configuration, so we can get it to match our codeing guidelines)
2) highlight syntax that does not match our coding guidelines
For example if a tool could format the sql so that all selects look like:
SELECT
tbl1.[ColumnX]
tbl2.[ColumnY]
FROM
tbl1
JOIN
tbl2 ON tbl1.[tbl2ID] = tbl2.[ID]
WHERE
tbl2.[ColumnZ] = 'XYZ'
Also if the tool could highlight situations were there are ON ERROR statements and suggest we use TRY CATCH for example.
Hopefully there are plugins that integrate right into the management studio.
Have you looked at SQL Prompt Pro from Red Gate ? It has layout functionality allowing you to layout your SQL to a shared style.
http://www.red-gate.com/products/SQL_Prompt/index.htm
You might want to check out Toad SQL Server beta
Andy
SSMS Tools is free and has a code layout feature.
I don't know of any static code analyzers for SQL Server. I tend just to search the code:
SELECT * FROM sys.sql_modules WHERE definition NOT LIKE '%BEGIN CATCH%'
I am a SQL Server developer, with a task in Oracle. DBA set up a DBLink in Oracle that points at a SQL Server database. I am writing a view on the SQL Server data and then a view on the Oracle side to join it with additional Oracle data.
Problem: if I change the definition of the view on SQL Server, even "Select * From myview#dblink" errors with "Invalid column." Closing TOAD and reopening seems to correct the problem, but the real question is how to force Oracle to re-read the metadata without resetting the connection?
This sounds like an issue with TOAD, not oracle. What happens if you do it in SQL*Plus?
I dont know if I understand you but if you got a dblink that points to a SQL server DB in your Oracle DB and you need data in SQL server just do:
SELECT *
FROM TABLE#dblink
SELECT "COL", "COL2", "COL3
from TABLE#dblink
SELECT T."COL", H."COL"
FROM TABLE1#dblink T, TABLE2#dblink H
WHERE T."ID" = H."ID"
Maybe you can do?:
alter view <<view_name>> compile;
I haven't tested this because I have no db link from Oracle to MSSQL.
This seems to be an issue with the Oracle 10g client. The current solution is to disconnect and reconnect. Given that I haven't been able to find anyone else with this problem, i will assume that it is a problem with my client config.