• ziangij (5/19/2010)


    thanks... but there is one issue though...

    1. create some user defined types in your database say UdtIntEntity

    2. when you execute this query, you will get one row for each type viz. Int, UdtIntEntity for the SAME table column.

    try this code...

    EXEC dbo.sp_addtype N'UdtIntEntity ', N'int',N'not null'

    EXEC dbo.sp_addtype N'udtDesc', N'varchar(500)',N'not null'

    EXEC dbo.sp_addtype N'udtName', N'varchar(500)',N'not null'

    CREATE TABLE [dbo].[abc](

    [col1] INT IDENTITY(1,1) NOT NULL

    ,[col2] VARCHAR(15) NOT NULL

    ,[col3] VARCHAR(500) NOT NULL

    CONSTRAINT [PK_abc_col1] PRIMARY KEY CLUSTERED

    (

    [col1] ASC

    )

    )

    then run your code for table abc...

    the output will be something like this...

    if not exists(select * from sysobjects where id = object_id('abc')

    and objectproperty(ID, N'IsUserTable') = 1)

    begin

    Create Table dbo.abc

    (

    [col1] int NOT NULL IDENTITY (1, 1)

    [col1] UdtIntEntity NOT NULL IDENTITY (1, 1)

    ,[col2] varchar(15) NOT NULL

    ,[col2] udtDesc NOT NULL

    ,[col2] udtName NOT NULL

    ,[col3] varchar(500) NOT NULL

    ,[col3] udtDesc NOT NULL

    ,[col3] udtName NOT NULL

    )