Monday, March 26, 2012

How to share user-defined data type in different database?

Hi,everyone.

I have defined a data type "OC_BUN_NAME" in database "CVPRO". I want to create a table tempdb.dbo.CVPRO in SQL SERVER 2005 system Database tempdb. But SQL SERVER 2005 DBMS gives a Error Messages:"Can not find the data type OC_BUN_NAME".

How can I do? How to use data types in the other database?

Please give me some advice. Thank you in advance.Hi
You should define the same data type in tempdb.
Also it would be good to define it in model database.
The tempdb is destroyed and recreated (from model) after each SQL Server restart. So if you define your data type in model database you do not have to redefine it in tempdb each time you reboot the server or restart SQL Server service.

Regards,
Kris Zywczyk|||Follow Kris, and also FYI,
http://vyaskn.tripod.com/sql_server_administration_best_practices.htm (http://vyaskn.tripod.com/sql_server_administration_best_practices.htm)|||Thank you,Kris Zywczyk.
Thank you, rudra.

However, after I define my data types in MODEL system databse, if I create a new database, the defined data types will automatically be added into the new database. I hope it can not happen. How can I do?

Thank you!|||Why do you want to create any tables in tempdb?|||Good lord. Don't even touch tempdb.
And in my opinion, don't bother with user-defined datatypes. They have little purpose.|||In SQL Server 2005, we can create a table in tempdb database so that different users can get access to data in the table. At the same time, when the SQL Server Services stop, tables created in tempdb database will be automatically destroyed. So in our project we want ot create a table in the tempdb database. However when we create the table, we can not use user-defined data type(the data types are defined in database "CVPRO"). Please give me some help.

Thanks!|||Hi
If you want to use user-defined data type you need to define it in current database (database where you create the table).

Can't you use standard tables in your 'CVPRO' database and delete it when it is not used?
You can always create the SQL Server Agent job dropping not needed tables and schedule it to run daily at i.e. 11 PM...

What exactly you want to do?

No comments:

Post a Comment