?
Solved

Invalid column prefix 'master.': No table name specified

Posted on 2007-08-02
4
Medium Priority
?
715 Views
Last Modified: 2008-02-26
I'm getting the following error message when I parse the below script:

"Invalid column prefix 'master.': No table name specified"

Here is my sample code:

DECLARE @DB VARCHAR (50)
declare @s nvarchar(3000)
SET @DB = 'PUBS'
--set @s = 'ALTER DATABASE'+ space(1) + @DB + space(1) + 'SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE'
set @s = 'ALTER DATABASE'+ space(1) + @DB + space(1) + 'SET MULTI_USER'


--restore reporting database
set @s = master..sqlbackup N'-SQL "RESTORE DATABASE ['+ @DB + ']
FROM DISK = ''\\ykcm1s1\y$\fromYKCMOS7\\Plandata_<DATETIME yyyymmdd>.sqb''  
WITH  MOVE ''kings_plus_reference_Data'' TO ''E:\data\' + SPACE (1)+ @DB + '.MDF'',
MOVE ''kings_plus_reference_Data_1'' TO ''E:\data\'+ SPACE (1)+ @DB + '_1.MDF'',
MOVE ''kings_plus_reference_Data_2'' TO ''E:\data\'+ SPACE (1)+ @DB + '_2.MDF'',
MOVE ''kings_plus_reference_Data_3'' TO ''E:\data\'+ SPACE (1)+ @DB + '_3.MDF'',
MOVE ''kings_plus_reference_Data_4'' TO ''E:\data\'+ SPACE (1)+ @DB + '_4.MDF'',
MOVE ''kings_plus_reference_Log'' TO ''F:\log\'+ SPACE (1)+ @DB + '_Log.LDF'', REPLACE"'"

exec sp_executesql @s

Any thoughts?
0
Comment
Question by:redouard
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19618149
>set @s = master..sqlbackup

you are missing the ' ' around the value..

set @s = ' master..sqlbackup  .... '
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 19618150
DECLARE @DB VARCHAR (50)
declare @s nvarchar(3000)
SET @DB = 'PUBS'
--set @s = 'ALTER DATABASE'+ space(1) + @DB + space(1) + 'SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE'
set @s = 'ALTER DATABASE'+ space(1) + @DB + space(1) + 'SET MULTI_USER'


--restore reporting database
set @s = 'master..sqlbackup  -SQL "RESTORE DATABASE ['+ @DB + ']
FROM DISK = ''\\ykcm1s1\y$\fromYKCMOS7\\Plandata_<DATETIME yyyymmdd>.sqb''  
WITH  MOVE ''kings_plus_reference_Data'' TO ''E:\data\' + SPACE (1)+ @DB + '.MDF'',
MOVE ''kings_plus_reference_Data_1'' TO ''E:\data\'+ SPACE (1)+ @DB + '_1.MDF'',
MOVE ''kings_plus_reference_Data_2'' TO ''E:\data\'+ SPACE (1)+ @DB + '_2.MDF'',
MOVE ''kings_plus_reference_Data_3'' TO ''E:\data\'+ SPACE (1)+ @DB + '_3.MDF'',
MOVE ''kings_plus_reference_Data_4'' TO ''E:\data\'+ SPACE (1)+ @DB + '_4.MDF'',
MOVE ''kings_plus_reference_Log'' TO ''F:\log\'+ SPACE (1)+ @DB + '_Log.LDF'', REPLACE"'

SELECT @s
0
 

Author Comment

by:redouard
ID: 19618342
Thank you for your response. I would like to schedule the above script via sql. How can I do that with the format you suggested?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 375 total points
ID: 19618466
simply create a sql server agent job, and paste that script as job step
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question