SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Rename Database


Rename Database

Author
Message
darren.thompson 95578
darren.thompson 95578
SSC Journeyman
SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)

Group: General Forum Members
Points: 86 Visits: 73
Comments posted to this topic are about the item Rename Database
travis.holmberg
travis.holmberg
SSC Rookie
SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)

Group: General Forum Members
Points: 31 Visits: 5

Great start with this thank you for your post! It looks like something that will be very useful to my team. One thing I wasn't sure of...
As written how does this sproc handle multiple secondary data files? At first glance, it looks like it doesn't. Is that right or am I misreading some of the script?


darren.thompson 95578
darren.thompson 95578
SSC Journeyman
SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)

Group: General Forum Members
Points: 86 Visits: 73
Hey Travis, I wasn't thinking about secondary files when I wrote this so you would have to modify it to do so.
dkellou
dkellou
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 92
darren.thompson 95578 - Monday, April 3, 2017 1:18 PM
Comments posted to this topic are about the item Rename Database

Hi, that's great script available only for the databases that have 1 data file .MDF and 1 log file .ldf
Can you modify and add rename task for secondary file .ndf thanks

Astigdaw
Astigdaw
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 65
Hi, I tried this stored procedure and it did not work because our system Administrator blocked access to

procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server.

Is there any work around?

Thanks.
Pete


darren.thompson 95578
darren.thompson 95578
SSC Journeyman
SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)

Group: General Forum Members
Points: 86 Visits: 73

Unfortunately, renaming a database is really a DBA task. This script blurs those lines between a DBA and a developer and some DBA's aren't going to allow it. So, there's not a good work around.

Having said that, ask your admin if they're willing to set it up as a job with an account that has privileges to run it.
(Note: This assumes you have access to kick off jobs.)


Steve Jones
Steve Jones
SSC Guru
SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)

Group: Administrators
Points: 139375 Visits: 19412
You can capture the output of the script and execute it directly instead of using xp_cmdshell.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Astigdaw
Astigdaw
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 65
darren.thompson 95578 - Friday, April 21, 2017 8:04 AM

Unfortunately, renaming a database is really a DBA task. This script blurs those lines between a DBA and a developer and some DBA's aren't going to allow it. So, there's not a good work around.

Having said that, ask your admin if they're willing to set it up as a job with an account that has privileges to run it.
(Note: This assumes you have access to kick off jobs.)



I was able to by do it by adding a step in front to turn on the cmdshell and turn off at the end. Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search