> The insert statement is being generated behind the scenes in a VB.Net program.
I would have guesses that. :-)
You can use Profiler to catch the insert statement. And then dig into ADO.NET and see how you can
"Chris Smith" <chris.smith@shaw.ca> wrote in message news:Fczsf.91873$2k.19886@pd7tw1no...
> That's interesting to "hear". The insert statement is being generated behind the scenes in a
> VB.Net program.
>
> I'll have to do some digging on this. But I have a new direction now. Thank you.
>
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in message
> news:uGPHxH5CGHA.1124@TK2MSFTNGP10.phx.gbl...
>> Most likely, you have an incorrect INSERT statement. My guess is that your INSERT statement
>> specifies a value (possibly NULL) for the TypeID column, which is why the default isn't
>> respected. I executed your CREATE TABLE statement, and then the below INSERT statement:
>>
>> INSERT INTO BookTypes (TypeDesc) VALUES('Hello')
>>
>> A values was indeed generated for the TypeID column.
>>
>> --
>> Tibor Karaszi, SQL Server MVP
>>
http://www.karaszi.com/sqlserver/default.asp >>
http://www.solidqualitylearning.com/ >> Blog:
http://solidqualitylearning.com/blogs/tibor/ >>
>>
>> "Chris Smith" <chris.smith@shaw.ca> wrote in message news:Otlsf.209874$Gd6.187567@pd7tw3no...
>>> The table was originally created as a simple little table, and with time I have added a couple
>>> of things with alter table - alter column and triggers. The Create Table statement now looks
>>> like:
>>> **************
>>>
>>> USE [MediaCollectionData]
>>>
>>> GO
>>>
>>> /****** Object: Table [dbo].[BookTypes] Script Date: 12/27/2005 17:59:42 ******/
>>>
>>> SET ANSI_NULLS ON
>>>
>>> GO
>>>
>>> SET QUOTED_IDENTIFIER ON
>>>
>>> GO
>>>
>>> CREATE TABLE [dbo].[BookTypes](
>>>
>>> [TypeID] [uniqueidentifier] NOT NULL CONSTRAINT [DefaultType] DEFAULT (newid()),
>>>
>>> [TypeDesc] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
>>>
>>> CONSTRAINT [PK_UniqueBookTypes] PRIMARY KEY CLUSTERED
>>>
>>> (
>>>
>>> [TypeID] ASC
>>>
>>> )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
>>>
>>> ) ON [PRIMARY]
>>>
>>>
>>>
>>> **************
>>> "Kalen Delaney" <replies@public_newsgroups.com> wrote in message
>>> news:uCBnNmpCGHA.3820@TK2MSFTNGP12.phx.gbl...
>>>>
>>>> Hi Chris
>>>>
>>>> Please show us the CREATE TABLE statement you are using, with the default value for TypeID.
>>>>
>>>> --
>>>> HTH
>>>> Kalen Delaney, SQL Server MVP
>>>>
www.solidqualitylearning.com >>>>
>>>>
>>>> "Chris Smith" <chris.smith@shaw.ca> wrote in message news:x01sf.193830$ki.77280@pd7tw2no...
>>>>>
>>>>> I HAVE put the newid() default value in for TypeID, but it does not seem to function.
>>>>>
>>>>> Field definitions are UniqueIdenfier for TypeID, and Varchar(50) for Desc.
>>>>>
>>>>>
>>>>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>>>>> news:Xns973924CECC6Yazorman@127.0.0.1...
>>>>>> Chris Smith (chris.smith@shaw.ca) writes:
>>>>>>> I am trying to create an INSTEAD OF trigger on a table that only has two
>>>>>>> fields: an ID and a description. The following code is not quite doing,
>>>>>>> well, anything that I have been able to figure out ...
>>>>>>
>>>>>> It would certainly help if you included the definition of BookTypes
>>>>>> and the INSERT statement you are using.
>>>>>>
>>>>>>> INSERT INTO BookTypes
>>>>>>> SELECT NewID() as TypeID, TypeDesc
>>>>>>> FROM inserted
>>>>>>
>>>>>> A general comment on style here: always provide a column list for your
>>>>>> INSERT statements. If another column is added to the table, this INSERT
>>>>>> statement will fail.
>>>>>>
>>>>>> By the way, why not simply use NEWID() as the default value for TypeID?
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
>>>>>>
>>>>>> Books Online for SQL Server 2005 at
>>>>>>
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx >>>>>> Books Online for SQL Server 2000 at
>>>>>>
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx >>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
>