Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2004
    Posts
    30

    Unanswered: Problem with 'CREATE DEFAULT ...' command

    Hi,

    Please help

    The following command works ok:
    create default [Zero] as 0

    but the command:
    if not exists (select * from dbo.sysobjects
    where id = object_id(N'[dbo].[Zero]')
    and OBJECTPROPERTY(id, N'IsDefault') = 1)
    create default [Zero] as 0

    returns:
    Server: Msg 156, Level 15, State 1, Line 3
    Incorrect syntax near the keyword 'default'.

    Env: Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

    Thanks
    Helena

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Just from a development point of view, I always do it this way...

    Code:
    /****** Object:  Default dbo.Zero    Script Date: 9/23/2004 10:18:34 AM ******/
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Zero]') and OBJECTPROPERTY(id, N'IsDefault') = 1)
    drop default [dbo].[Zero]
    GO
    
    /****** Object:  Default dbo.Zero    Script Date: 9/23/2004 10:18:35 AM ******/
    create default [Zero] as 0
    
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Sep 2004
    Posts
    30
    Hi Brett,

    I KNOW that is the way to do it
    (if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Zero]') and OBJECTPROPERTY(id, N'IsDefault') = 1)
    drop default [dbo].[Zero]
    GO
    )

    but I can't make it work.

    The return error is :
    Server: Msg 156, Level 15, State 1, Line 3
    Incorrect syntax near the keyword 'default'.

    Do you know what could be the problem ?
    - Please Help !!!!!

    Helena

  4. #4
    Join Date
    Sep 2004
    Posts
    30
    Hi Brett,

    Thank You for the solution

    Helena

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •