I can use the following successfully:
SELECT OBJECT_ID('myDB..myTable')
but on a linked server I cannot get this working. Is this the right syntax?
Should it work? The server name is box. This gives me a syntax error near
myDB.
Select * From Openquery(box, 'SELECT OBJECT_ID('myDB..myTable')')Try something like this:
DECLARE @.sql NVARCHAR(2000)
SELECT @.sql = 'SELECT OBJECT_ID(''myDB..myTable'')'
PRINT @.sql
EXEC linkedserver..sp_executesql @.sql
MeanOldDBA
derrickleggett@.hotmail.com
http://weblogs.sqlteam.com/derrickl
When life gives you a lemon, fire the DBA.
"Derek Hart" wrote:
> I can use the following successfully:
> SELECT OBJECT_ID('myDB..myTable')
> but on a linked server I cannot get this working. Is this the right synta
x?
> Should it work? The server name is box. This gives me a syntax error near
> myDB.
> Select * From Openquery(box, 'SELECT OBJECT_ID('myDB..myTable')')
>
>|||You need to double the inner single quotes:
Select * From Openquery(box, 'SELECT OBJECT_ID(''myDB..myTable'')')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Derek Hart" <derekmhart@.yahoo.com> wrote in message news:uiEB$MieGHA.4304@.TK2MSFTNGP05.phx
.gbl...
>I can use the following successfully:
> SELECT OBJECT_ID('myDB..myTable')
> but on a linked server I cannot get this working. Is this the right synta
x? Should it work? The
> server name is box. This gives me a syntax error near myDB.
> Select * From Openquery(box, 'SELECT OBJECT_ID('myDB..myTable')')
>
No comments:
Post a Comment