Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Support for User Defined Types

Author  Topic 

jstrunk
Starting Member

4 Posts

Posted - 2009-10-11 : 14:33:15
I am trying to do the JDBC Tutorial with SQL Server Express 2008.

When I do this

String createAddress = "CREATE TYPE ADDRESS (NUM INTEGER, " +
"STREET VARCHAR(40), CITY VARCHAR(40), " +
"STATE CHAR(2), ZIP CHAR(5))";

stmt.executeUpdate(createAddress);

I get "Incorrect syntax near '('.".

I've seen some things online that imply that this syntax for creating a STRUCT is not supported and I have to use .NET CLR or Visual Studio instead. Is this true? Is there any way to do it in Java instead? I am just trying to learn JDBC and it seems like a pretty big detour to have to figure out another compiler.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-11 : 14:38:37
do you mean this?

String createAddress = "CREATE TYPE ADDRESS AS TABLE (NUM INTEGER, " +
"STREET VARCHAR(40), CITY VARCHAR(40), " +
"STATE CHAR(2), ZIP CHAR(5))";
Go to Top of Page

jstrunk
Starting Member

4 Posts

Posted - 2009-10-12 : 11:03:12
I dont think so. I am trying to create a new User Defined Type, not a table.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-10-12 : 12:15:50
I'm not sure about Java, but I belive you have to register the type. From BOL:
quote:
To bind a user-defined type to its implementation, the CLR assembly that contains the implementation of the type must first be registered in SQL Server by using CREATE ASSEMBLY.
Again, I'm not expert of this as I have not used user-defined types.
Go to Top of Page
   

- Advertisement -