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

need NULL defined when adding to the table Expand / Collapse
Author
Message
Posted Tuesday, October 15, 2013 2:48 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, September 5, 2014 9:10 PM
Points: 163, Visits: 569
I need your help. I have instruction to update a table. The instruction is simple "IsValidSap (should have null defined when adding to the table)". I am unclear about what is needed. I know you can set defaults on tables if no value is sent into the insert statement. But this wordking is confusing for me and unsure that is what is being asked. For those out there with much more SQL experience then me I ask for your interpretation of what you think is being asked?

Table definition:

USE [ReceiptRepository]
GO

/****** Object: Table [Lkup].[ReceiptReasonCodes] Script Date: 10/15/2013 13:21:35 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [Lkup].[ReceiptReasonCodes](
[ReceiptReasonCodeId] [int] IDENTITY(-2147483648,1) NOT NULL,
[ReceiptReasonCode] [varchar](4) NOT NULL,
[ReceiptReasonCodeMultiplier] [decimal](4, 2) NOT NULL,
[LongDescription] [varchar](255) NOT NULL,
[BillingEntityTypeId] [int] NULL,
[IsMergeAllowedFlag] [bit] NOT NULL,
[ActiveFlag] [char](1) NOT NULL,
[InsertedBy] [varchar](128) NOT NULL,
[InsertTs] [datetime] NOT NULL,
[UpdatedBy] [varchar](128) NOT NULL,
[UpdateTs] [datetime] NOT NULL,
[PaymentClassificationId] [int] NULL,
[color=#FF0000][IsValidSap] [bit] NULL,[/color]
CONSTRAINT [PK_ReceiptReasonCodes_ReceiptReasonCodeId] PRIMARY KEY CLUSTERED
(
[ReceiptReasonCodeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] WITH CHECK ADD CONSTRAINT [FK_ReceiptReasonCodes_BillingEntityTypes_BillingEntityTypeId] FOREIGN KEY([BillingEntityTypeId])
REFERENCES [Lkup].[BillingEntityTypes] ([BillingEntityTypeId])
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] CHECK CONSTRAINT [FK_ReceiptReasonCodes_BillingEntityTypes_BillingEntityTypeId]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] WITH CHECK ADD CONSTRAINT [FK_ReceiptReasonCodes_PaymentClassifications_PaymentClassificationId] FOREIGN KEY([PaymentClassificationId])
REFERENCES [Lkup].[PaymentClassifications] ([PaymentClassificationId])
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] CHECK CONSTRAINT [FK_ReceiptReasonCodes_PaymentClassifications_PaymentClassificationId]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] ADD CONSTRAINT [DC_ReceiptReasonCodes_IsMergeAllowedFlag] DEFAULT ((0)) FOR [IsMergeAllowedFlag]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] ADD CONSTRAINT [DC__ReceiptReasonCodes__ActiveFlag] DEFAULT ('Y') FOR [ActiveFlag]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] ADD CONSTRAINT [DC__ReceiptReasonCodes__InsertedBy] DEFAULT (suser_sname()) FOR [InsertedBy]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] ADD CONSTRAINT [DC__ReceiptReasonCodes__InsertTs] DEFAULT (getdate()) FOR [InsertTs]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] ADD CONSTRAINT [DC__ReceiptReasonCodes__UpdatedBy] DEFAULT (suser_sname()) FOR [UpdatedBy]
GO

ALTER TABLE [Lkup].[ReceiptReasonCodes] ADD CONSTRAINT [DC__ReceiptReasonCodes__UpdatedTs] DEFAULT (getdate()) FOR [UpdateTs]
GO







A clever person solves a problem. A wise person avoids it.
A clever person solves a problem. A wise person avoids it.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Post #1504984
Posted Tuesday, October 15, 2013 2:57 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:31 AM
Points: 40,456, Visits: 36,912
Maybe ask whoever gave you that requirement for clarification? We can guess what that person meant, but we'll probably be wrong.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1504988
Posted Tuesday, October 15, 2013 3:16 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, September 5, 2014 9:10 PM
Points: 163, Visits: 569
The person is inexcessable for the next two weeks and this needs to be completed before that time. You have as much information as I do about it, so from what you said it sounds like this verbiage is ambigious and vague as I suspected. The person is a senior programmer and because I am not I wanted to check with the forum in case it means something clear to people more experienced than me?

Thanks for your reply







A clever person solves a problem. A wise person avoids it.
A clever person solves a problem. A wise person avoids it.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Post #1504995
Posted Tuesday, October 15, 2013 3:28 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:09 AM
Points: 2,268, Visits: 3,429
I think the code below is a reasonable interpretation, but whether it's correct or not is far from certain:


ALTER TABLE [Lkup].[ReceiptReasonCodes]
ADD [IsValidSap] [bit] NULL




SQL DBA,SQL Server MVP('07, '08, '09)

Carl Sagan said: "There is no such thing as a dumb question." Sagan obviously never watched a congressional hearing!
Post #1505002
Posted Tuesday, October 15, 2013 3:36 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:31 AM
Points: 40,456, Visits: 36,912
ScottPletcher (10/15/2013)
I think the code below is a reasonable interpretation, but whether it's correct or not is far from certain:


If the table definition posted is correct, the column already exists (as a nullable column) in the table.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1505005
Posted Tuesday, October 15, 2013 3:41 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, September 5, 2014 9:10 PM
Points: 163, Visits: 569
That column is already in the table definition i provided. That table/column already allows NULLs. My guess is that the persom wants a default value set to the column rather then NULLs being there. The potentially problem with making that change is that any number of other sprocs/functions/scripts could be hitting this table and column and a change like that could impact any number of unknown processes. I think the chick just wants to screw me because i am new and they are senior and politically connected






A clever person solves a problem. A wise person avoids it.
A clever person solves a problem. A wise person avoids it.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Post #1505009
Posted Tuesday, October 15, 2013 4:09 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:15 PM
Points: 6,842, Visits: 13,370
If you need to update the table, then the question is: what rules do apply?
The table is already defined as requested ("IsValidSap (should have null defined when adding to the table)") so there's nothing to do with this part.
Therefore, there's no need to update (= alter) the table (definition).
It might be to fill the new column with values based on certain (unknown) requirements.

If the application still runs without any error, I would leave it as it is. In case it fails, it might be due to a bad coding habit of not referencing all column names in an insert statement. In such a case address it to the App Dev team.

Whoever request you to finish this task should describe what's expected. If this can't be done, the implementation of the "requirement" should be postponed until clarification is available.




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1505014
Posted Tuesday, October 15, 2013 6:22 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, September 5, 2014 9:10 PM
Points: 163, Visits: 569
Thank you. That is solid good advice. Your right best not to mess with it until clarification can be achieved.






A clever person solves a problem. A wise person avoids it.
A clever person solves a problem. A wise person avoids it.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Post #1505034
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse