Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

using isnull function in select query Expand / Collapse
Author
Message
Posted Monday, July 15, 2013 2:47 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 5:04 AM
Points: 79, Visits: 207

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
Post #1473528
Posted Monday, July 15, 2013 2:57 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 8:25 AM
Points: 4,983, Visits: 11,675
What's your question?


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1473531
Posted Monday, July 15, 2013 3:04 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 5:04 AM
Points: 79, Visits: 207
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
Post #1473536
Posted Monday, July 15, 2013 3:11 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 8:25 AM
Points: 4,983, Visits: 11,675
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.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1473542
Posted Monday, July 15, 2013 3:20 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 5:04 AM
Points: 79, Visits: 207
solved
Post #1473544
Posted Monday, July 15, 2013 3:25 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 8:25 AM
Points: 4,983, Visits: 11,675
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.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1473549
Posted Monday, July 15, 2013 3:29 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 14, 2014 11:21 PM
Points: 1, Visits: 41
if solved please post ur solution surekha..
Post #1473550
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse