Question/Issue with User Defined Data types
kfilipowsky
Posts: 14
I have created a command line application used to promote select database objects between environment for developers. This is working very well with one exception.
I create a DB object for testing as follows:
sp_addtype @typename='testusertype', @phystype='datetime', @nulltype='not null',@owner='dbo'
It is a standard here that all objects must be owned by 'dbo'
When I migrate the user type with my utility, it is created on the target server but the owner is set to the Id running my command line utility, not dbo as it existed in its original form.
Following is an excerpt from the SQL generated by Redgate's API
sp_addtype N'testusertype', 'datetime', 'NOT NULL'
note the absense of @owner option. The source object is dbo.testusertype and target object ends up being filipowsky_adm.testusertype
Can you offer any advise here? If this an issue with the API or am I missing something in my code?
Karl Filipowsky
Pfizer Animal Health | Global Shared Services
Desk: 269-833-0990 | Cell: 734-216-4392 | Fax: 269-833-2255
I create a DB object for testing as follows:
sp_addtype @typename='testusertype', @phystype='datetime', @nulltype='not null',@owner='dbo'
It is a standard here that all objects must be owned by 'dbo'
When I migrate the user type with my utility, it is created on the target server but the owner is set to the Id running my command line utility, not dbo as it existed in its original form.
Following is an excerpt from the SQL generated by Redgate's API
sp_addtype N'testusertype', 'datetime', 'NOT NULL'
note the absense of @owner option. The source object is dbo.testusertype and target object ends up being filipowsky_adm.testusertype
Can you offer any advise here? If this an issue with the API or am I missing something in my code?
Karl Filipowsky
Pfizer Animal Health | Global Shared Services
Desk: 269-833-0990 | Cell: 734-216-4392 | Fax: 269-833-2255
Comments
I've had a look into this and I think it may be a design issue with the SQL Compare Engine. Because it does not fiddle with object ownership, migrating objects that were created with implicit ownership as the currently-logged-in-user, maybe it made more sense to strip the ownership from user-defined types as well. I'll raise this with the developers, but I have a feeling they are going to tell me the same thing.
if not, we'll just drop UDTs from the automation plan, we only have a few of those a year anyway.
No, the executionblock is read-only. Either you need to make sure you connect to the database and execute the block with a user that's part of the DBO role, or save the script to a file and manipulate it and run it outside of the Toolkit.