Hi ALL,
I'd like to have a help to the problem.
If I make a SELECT as:
select * from [LS].[msdb].[dbo].[sysfiles]
(hier LS is a linked server) it working fine.
The following lines dont work:
DECLARE @.STR NVARCHAR ( 300 )
SELECT @.STR =3D 'select * from [LS].[msdb].[dbo].[sysfiles]'
EXECUTE @.STR
I get the message:
Server: Nachr.-Nr. 203, Schweregrad 16, Status 2, Zeile 3
Der Name 'SELECT * FROM [LS].[msdb].[dbo].[sysfiles]' ist
kein g=FCltiger Bezeichner.
Whot is wrong?=20
How can I correct it?
Regards
SimonHi,
Enclose the varible in parenthesis execute (@.STR)
DECLARE @.STR NVARCHAR ( 300 )
SELECT @.STR = 'select * from [LS].[msdb].[dbo].[sysfiles]'
execute(@.STR)
Or use the below query using sp_executesql
DECLARE @.STR NVARCHAR ( 300 )
SELECT @.STR = 'select * from [LS].[msdb].[dbo].[sysfiles]'
exec sp_executesql @.STR
Thanks
Hari
MCDBA
"Simon" <anonymous@.discussions.microsoft.com> wrote in message
news:2ae0c01c46805$524e12b0$a501280a@.phx
.gbl...
Hi ALL,
I'd like to have a help to the problem.
If I make a SELECT as:
select * from [LS].[msdb].[dbo].[sysfiles]
(hier LS is a linked server) it working fine.
The following lines dont work:
DECLARE @.STR NVARCHAR ( 300 )
SELECT @.STR = 'select * from [LS].[msdb].[dbo].[sysfiles]'
EXECUTE @.STR
I get the message:
Server: Nachr.-Nr. 203, Schweregrad 16, Status 2, Zeile 3
Der Name 'SELECT * FROM [LS].[msdb].[dbo].[sysfiles]' ist
kein gltiger Bezeichner.
Whot is wrong?
How can I correct it?
Regards
Simon
No comments:
Post a Comment