Dave Johnson
Dave Johnson

Reputation: 825

User Defined Type change

I want to implement a user defined type (table) in SQL Server (2008 R2) that is passed from a VB.NET application. This will be a generic type used in place of passing comma-delimited lists (at least initially it will be exclusively ID values).

If it is decided later that we need to modify the UDT, will we also need to change everywhere in the application code that we attempt to use the UDT? Or can we get around having to do such a thing by making a new column in the UDT nullable?

The concern is that if we want to add a new column to the table we will need to go back and change all the places this UDT is used in the application, whether those places will need the new column or not.

Upvotes: 0

Views: 164

Answers (1)

blindguy
blindguy

Reputation: 1009

You should be able to add columns to the UDT as long as they DO allow NULL values.

As far as the application code, it will depend on what you are calling. If you want to add data to the new column, you will need to change the code where you are inserting rows. If you are retrieving the data, you will need to change the code to get the data from the new column.

Are you asking if changing the UDT on the server side will require immediate changes to your code? You should not need to. SELECT queries in VB require you to access each column specifically after each query so additional columns should not affect the code. Same with inserting rows: if you are using cmd.CommandText = "INSERT INTO table (field1, [field2, ... ]) VALUES (value1, [value2, ...])" then each column is specifically labeled and additional columns should not affect the application unless the no not allow NULL.

Upvotes: 1

Related Questions