SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


need NULL defined when adding to the table


need NULL defined when adding to the table

Author
Message
TeraByteMe
TeraByteMe
SSC Veteran
SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)

Group: General Forum Members
Points: 285 Visits: 589
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. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89289 Visits: 45284
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, MVP, M.Sc (Comp Sci)
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


TeraByteMe
TeraByteMe
SSC Veteran
SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)

Group: General Forum Members
Points: 285 Visits: 589
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. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
ScottPletcher
ScottPletcher
SSCrazy Eights
SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)

Group: General Forum Members
Points: 8072 Visits: 7163
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)[size=2]Prosecutor James Blackburn, in closing argument in the Fatal Vision murders trial: If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them.[/size]
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89289 Visits: 45284
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, MVP, M.Sc (Comp Sci)
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


TeraByteMe
TeraByteMe
SSC Veteran
SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)

Group: General Forum Members
Points: 285 Visits: 589
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. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10549 Visits: 13559
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
TeraByteMe
TeraByteMe
SSC Veteran
SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)SSC Veteran (285 reputation)

Group: General Forum Members
Points: 285 Visits: 589
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. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search