Basically I produce an accounts package that uses a SQL 2000 DB as the
RDBMS. I always instruct users to login as 'sa' and the relevant
password when doing an update to my program, as sometimes I need to do
database changes for new stuff.
Found that one of my users has not only logged in with their login
name (in this case Edward), but have also made this login a 'db owner'
so that when I created 2 new user-defined data types they belong to
Edward rather than dbo.
This must have happened a long time ago, but now that they want to
move Edward round the roles and/or delete him from a copy of the
database that they have, they can't because he's the owner of these
user-defined types.
This brings me to the reason for my post, how can I change the owner
from Edward to dbo for these data types? I found an article on
technet of how to do this, but when it suggests changing my
user-defined type to standard format it doesn't seem to work.
Is there a way to change the physical mapping of a user defined data type to the physical SQL Server datatype. It seems that once you create them, it is just about impossible to change it.
We have a database that originally had all objects owned by a vendor id. We are in the process of changing the ownership to 'dbo' and wish to remove the vendor id but have found there are a few user defined datatypes that are also owned by this vendor id. How can I change the ownership of them to 'dbo'? They are currently being used in some of the tables. I tried the sp_changeobjectowner but that doesn't work for these.
what are the advantages of using user-defined data types in SQL Server?
for example, you may have Customer Number Cust_Num varchar(10) you can create a user-defined data type like this: udt_CustNum
so now your table creation script for Custome table become: Cust_Num udt_CustNum
however, once the user-defined data type is referred by other tables. it cannot be changed/deleted.
So, i wonder what are the good reason of using udt instead of fundamental data types. (built-in datatypes)
the only good thing i think is about: the abstract naming of the data type. you may have other key fields like Supplier Number which is varchar(12) instead of u have to remember varchar(10) for customer and varchar(12) for supplier u just to remember udt_CustNum for customer and udt_SuppNum for supplier.
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?
Im trying to use a .NET IPAddress in my UDT. i create the assembly, but i get this error when i try to create the type in SQL Server:
Type "IPAddress.IPAddressUDTType" is marked for native serialization, but field "address" of type "IPAddress.IPAddressUDTType" is not valid for native serialization.
From what i understand about the IPAddress object in .NET it is serializable. what am i doing wrong
( note, im just doing this for research purposes and not planing to use the UDT)
I created a user-defined datatype in Microsoft SQL server using the Enterprise Manager. But, I am not able to find options to edit this data type. There are options to delete but not for editing an existing user defined data type.
Can any one help me how to edit this user defined datatype ?
Also, are there any better ways to create and manage user defined data types in MS SQL ?
What is 'COLLATE SQL_Latin1_General_CP1_CI_AS'? I am new to SQLServer, and couldn't find much information on the Web. Also, I am trying to understand user defined data types. For example,
In the following example, what is '[Price_DT]' data type? and how would it be referenced at the time of 'INSERT'.
CREATE TABLE [dbo].[Dist_Orders_Master_Index] ( [SubTotal] [Price_DT] NOT NULL , [Tax] [Price_DT] NOT NULL ) ON [PRIMARY]
I have several stored procedures with parameters that are defined withuser defined data types. The time it takes to run the procedures cantake 10 - 50 seconds depending on the procedure.If I change the parameter data types to the actual data type such asvarchar(10), etc., the stored procedure takes less that a second toreturn records. The user defined types are mostly varchar, but someothers such as int. They are all input type parameters.Any ideas on why the stored procedure would run much faster if notusing user defined types?Using SQL Server 2000.Thanks,DW
Hello, I cannot find out to create enum data type in SQL Server 2005 Express. Can I easily create the enum type just like the MySQL does.(please the MySQL example below)
CREATE TABLE myTable ( myid INT UNSIGNED NOT NULL, myclass ENUM('FIRST','SECOND','THIRD') DEFAULT 'FIRST' PRIMARY KEY(myid) );
Hello, We had a developer that created some user defined data types. He is no longer with our company and we want to change owner of those user defined data types so we will be able to delete his UUID. Is their a way to change the owner of the user defined data types from his ID to dbo. I don't see a way to change them with sp_changeobjectowner
Implement time interval type in the form of a user defined type in SS2k8r2? Specifically an interval type described in the book Temporal Data and the Relational Model by C. J. Date at all. As an example, an interval is below:
1/4/2006:1/10/2006
which would mean the time period from 1/4 to 1/10.
Usually all the user datatypes in our databases have the owner dbo. One has a few that are owned by a user with dbo rights. I am trying to change them to dbo owner. Sp_changeobjectowner gives 'object does not exist'
A common request for enhancement to applications is to "make thisfield bigger". I know I've been caught with increasing a field size,and then spending hours debugging because another stored proc has avariable or temp table that uses the field defined as the originalvarchar size. SQL Server just truncates to fit the data into thesmaller varchar, and so there are no errors raised.An option suggested by a colleague is to no longer use varchars, butuse User Defined Types instead. To make this work effectively,though, they suggest we would need to make it a rule that we do notuse varchars anywhere except to define user defined types.Though there will be one point of changes I can't help thinking thisisn't a very good idea ! Any thoughts ?Thanks.
I've got a user defined table type called StringDictionaryTVP:
CREATE TYPE [dbo].[StringDictionaryTVP] AS TABLE( [key] [varchar](500) NULL, [value] [varchar](500) NULL )
Ideally I would like to be able to have a # of columns and directions in this table like so:
DECLARE @OrderByClause StringDictionaryTVP
INSERT INTO @OrderByClause([key], [value]) values('gender','desc') INSERT INTO @OrderByClause([key], [value]) values('name','asc')
Since our database can be a bit sizable, I'd also like to use Common Table Expressions so I can page through them fairly easy.So my standard cte is something like this:
DECLARE @PageIndex INT = 0 DECLARE @PageSize INT = 20 ;WITH results_cte AS ( SELECT U.*, ROW_NUMBER() over ( ORDER BY name ) RowNum from Users U) SELECT * FROM results_cte WHERE RowNum > @Offset AND RowNum <= @Offset + @PageSize
So where 'ORDER BY name' is I'd like to use the @OrderByClause in some sort of dynamic way. I've tried all kinds of stuff but even something like this doesn't get the actual column name I need
;WITH results_cte AS ( SELECT U.*, ROW_NUMBER() over ( ORDER BY (select top 1 [key] +' '+ [value] from @OrderByClause) ) RowNum from Users U)
I may be chasing the wrong stick, but outside of dynamic sql, is something like this possible?
Is there a syntax to create indexes on user-defined type's fields and methods? Can I index UDT-fields?
I tried but only get syntax error.
Code Snippet
-- put an index on the picture luminance
CREATE INDEX myIdx ON myTbl(picMetaData.Brightness) -- !! error
GO
Error message:
Code Snippet
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
According to books online (BOL), section User-defined types requirements says In the SQL Server 2005 RTM version, CLR UDTs with user-defined serialization were allowed to have their fields indexed as part of non-persisted computed columns or views. In such situations, non-deterministic UDT serialization/deserialization could lead to index corruption, and therefore has been removed from SQL Server 2005 SP1. In SQL Server 2005 SP1, UDT fields must use native serialization or be persisted in order to be indexed. Any existing indexes on UDT fields should continue to function as before.
What are BOL trying to say about index on UDT fields?
Hi all. We have a mix of informix and mssql server and I want to know if something we do in informix has an analogous feature in MSSQL. We can define a "row type" in informix, like so:
create row type name_1(fname char(20),lname char(20));
The when we create any table that includes a first and last name, we do so using this row type like so:
create table sometable(name name_1, some column,...etc)
This allows us to set a standard for certain common fields and avoids having different developers build the same type of field in more than one way, different lengths, etc.
Hi all, In my SQL Server Management Studio Express, I have the following Database "ChemAveRpd", Table "dbo.LabTests", and Content of the Table: dbo.LabTests Column_name Type Length Prec Scale AnalyteID int 4 10 0 (Primary Key) AnalyteName nvarch 510 CasNumber nvarch 510 Result numeric 5 8 2 Unit nvarch 510 SampleID int 4 10 0 (Foreign Key)
Dear all, I'm using sqldatareader to return data that i need and then bind it to the gridview. Anyway, I'm facing the above error message. Please help, thanks. Levine
I am trying to bind the data to a list box....i am using a stored procedure instead of a select query. Unfortunately the error is throwing up. Correct me where iam going wrong. Is my syntax correct SqlConnection cn = new SqlConnection("User id=******;password=******;database=sampleecsphase2test;Data source=primasqltst\qa"); cn.Open();SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure;SqlDataReader dr = new SqlDataReader(); dr = cmd.ExecuteReader(); listBox1.DataSource = dr;
Use databases a bit, but new to SQL Server. We just want to change a column of existing SQL Server 2005 data from a string data type to one of the UNiCODE data types, such as DT_WSTR or DT.NTEXT (such as one can use for various data mining tasks, etc.). It seems to do this one needs to "the data conversion transformation editor". To use that one has to have a package and a project?
Does any one have a full script or set of steps to do the full set of steps for what should be a simple task? This would be a great example for BOL, but each atomistic bit of BOL refers to another, and one gets lost in the circle when a complete example is needed for fundamantal housekeeping tasks.
I am not very familiar with working with spatial data and I am currently trying to work out how to obtain some properties of a circle defined as a geometry data type. Specifically, I need to determine x and y co-ordinates for the centre point and the diameter of the circle.I have had a look at the MSDN reference for spatial data .
Good Afternoon, I have recently been tasked to come up with a means by which to create SQL data pulls based on user entries. What I mean by this is, I will have a pre defined SQL data pull set up and the user can then select the criteria upon which to pull said data. So, say I want to display a table where one of the colums has is the "Year". I dont however want all years of data pulled, only 2005 - 2006. So, in form field 1, I could select start year as 2005 and in form field 2, I could select end year as 2006. This would then give me all data from this table based on that year range, or whatever year range I select and submit. Is there a way to do this in ASP? I have been reading up on UDF with SQL, but I cant find anything about linking it through the use of web forms or through ASP. Or if there is another way to accomplish this? Any assistance is very much appreciated!
I want to change a column's data type from bit to int. There are data in the table already. I'm wondering if it is save/correct way to issue the following command to change the data type for that column.ALTER TABLE database_tableALTER COLUMN my_bit_column INT; Thanks.