Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Moving WSUS Database SBS2011

Posted on 2014-02-02
6
Medium Priority
?
1,974 Views
Last Modified: 2016-02-20
Hello,

I tried following these directions --> http://www.blackmanticore.com/caa80f452a8fb0337dfc80875e79dddc 

To move my susdb.mdf and SUSDB_log.ldf from my C:\WSUS\SUSDB\UpdateServicesDbFiles folder to P:\WSUS\Database as my C:\ is running low on space and the database is around 13GB. All went well up until the point I need to mount the database back. When I try run the command

sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_attach_db @dbname=N'SUSDB',\
       @filename1=N'P:\WSUS\Database\SUSDB.mdf',\
       @filename2=D'P:\WSUS\Database\SUSDB_log.ldf"

I get this:

C:\Windows\system32>sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q
"sp_attach_db @dbname=N'SUSDB',\
Msg 105, Level 15, State 1, Server SERVERNAME\MICROSOFT##SSEE, Line 1
Unclosed quotation mark after the character string 'sp_attach_db @dbname=N'SUSDB
','.
Msg 102, Level 15, State 1, Server SERVERNAME\MICROSOFT##SSEE, Line 1
Incorrect syntax near 'sp_attach_db @dbname=N'SUSDB','.

C:\Windows\system32>       @filename1=N'P:\WSUS\Database\SUSDB.mdf',\
'filename1' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\system32>       @filename2=D'P:\WSUS\Database\SUSDB_log.ldf"

I tried connecting with management studio express to try attach the database from there but it can no longer connect to MICROSOFT##SSEE. What is the correct systax I should use or how can i get this database re attached?

FYI, my OS is SBS2011
0
Comment
Question by:Mark Rohrbeck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39828344
you might have put the SQLCMD command in multiple lines... which is not getting accepted


try this one,put them all in one line and it should work.

sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_attach_db @dbname=N'SUSDB',@filename1=N'P:\WSUS\Database\SUSDB.mdf',@filename2=D'P:\WSUS\Database\SUSDB_log.ldf"

Open in new window

0
 

Author Comment

by:Mark Rohrbeck
ID: 39828360
After running that I get the following:

C:\Windows\system32>sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q
"sp_attach_db @dbname=N'SUSDB',@filename1=N'P:\WSUS\Database\SUSDB.mdf',@filenam
e2=D'P:\WSUS\Database\SUSDB_log.ldf"
Msg 105, Level 15, State 1, Server CELERASERVER\MICROSOFT##SSEE, Line 1
Unclosed quotation mark after the character string 'P:\WSUS\Database\SUSDB_log.l
df
'.

C:\Windows\system32>

Open in new window

0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39828366
spotted it now, the unclosed quotation mark is at the end of the statement, right after susdb_log.ldf.

Added that now and the code is below, give it a try and let us know the results.

C:\Windows\system32>sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q
"sp_attach_db @dbname=N'SUSDB',@filename1=N'P:\WSUS\Database\SUSDB.mdf',@filenam
e2=D'P:\WSUS\Database\SUSDB_log.ldf'"

Open in new window

0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 16

Accepted Solution

by:
Surendra Nath earned 2000 total points
ID: 39828374
I also see that there is another issue here that you are using the @filename2 = D' where as it should be @filename2 = N'

C:\Windows\system32>sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q
"sp_attach_db @dbname=N'SUSDB',@filename1=N'P:\WSUS\Database\SUSDB.mdf',@filenam
e2=N'P:\WSUS\Database\SUSDB_log.ldf'"

Open in new window

0
 

Author Comment

by:Mark Rohrbeck
ID: 39828390
That did the trick. You my friend are my hero. THANK YOU. Question... what do the "D" and "N" values represent?
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39828397
There is nothing as D in SQL Server... it is syntactically wrong.
N means it is a NVARCHAR data type not a VARCHAR dataType. NVARCHAR datatype can hold charecter outside the normal ASCII range.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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