Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.
One of the things I needed to do recently was move an object. I was testing the WideWorldImporters database and created an object in the dbo schema. That’s the default for me, which is fine. However, in this case I wanted it in a different schema.
The way to do this is with the ALTER SCHEMA command. There is a TRANSFER option, which takes the original schema and object name.
In my case, I had the dbo.GetOpenPurchaseOrderCount procedure in my database.
I used this command to move it.
ALTER SCHEMA Website
TRANSFER dbo.GetOpenPurchaseOrderCount
And then verified things moved.
SQLNewBlogger
This was one of those quick items where I checked the ALTER commands, thinking it was in there. I didn’t see a changeobjectschema procedure, and since this was a new skill, it was a 5 minute blog.