using isnull function in select query

  • select isnull(id,0)+1 as ID from TABLE1

    i have the id field blank with defualt value as 0

    but when i use the abobe query i dont get 1

    select isnull(id,0) as ID from TABLE1 i dont get 0

  • What's your question?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • i have a int column as Custid

    initally value is balnk.

    but i have set the default value when creating the field as 0

    i need to increment the max Custid value

    but if its null i need it be 0 so incrementing it would be 1

    select isnull(Custid,0)+1 as ID from TABLE1

    i have the Custid field blank with defualt value as 0

    but when i use the abobe query i dont get 1

    select isnull(Custid,0) as ID from TABLE1 i dont get 0

  • ssurekha2000 (7/15/2013)


    i have a int column as Custid

    initally value is balnk.

    but i have set the default value when creating the field as 0

    i need to increment the max Custid value

    but if its null i need it be 0 so incrementing it would be 1

    select isnull(Custid,0)+1 as ID from TABLE1

    i have the Custid field blank with defualt value as 0

    but when i use the abobe query i dont get 1

    select isnull(Custid,0) as ID from TABLE1 i dont get 0

    Can you provide DDL and sample data so that I can see what your source data looks like? See the link in my signature for details of how to do this.

    Note that there is (potentially) a difference between 'NULL' and 'blank'.

    And still you have not asked a question.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • solved

  • ssurekha2000 (7/15/2013)


    CREATE TABLE [dbo].[DETAILS](

    [ID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,

    [CLENO] [int] NOT NULL CONSTRAINT [DF_DETAILS_CLENO] DEFAULT ((0)),

    [Custid] [int] NOT NULL CONSTRAINT [DF_DETAILS_Custid] DEFAULT ((0)),

    CONSTRAINT [PK_DETAILS] PRIMARY KEY CLUSTERED

    (

    [ID] ASC

    )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]

    ) ON [PRIMARY]

    Still no sample data and no questions ... I'm out.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • if solved please post ur solution surekha..

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply