Forum,
I am looking at another report code (constructed by another user) and wanted to know why the user coded the word NULL after each field in the Temp tables. What does the NULL tell me and why would the user use it? Sorry for the Newb question ... I'm still learning the language and could not find any information in the help files.
Report Code
/* Billing Status */
SET NOCOUNT ON
CREATE TABLE #Appt( FacilityId int NULL,
Visit datetime NULL,
OwnerId int NULL,
DoctorId int NULL,
CompanyId int NULL,
ApptSetId int NULL,
CasesId int NULL
)
CREATE TABLE #Temp( Visit datetime NULL,
PatientId varchar(15) NULL,
PatientName varchar(90) NULL,
DoctorName varchar(60) NULL,
ApprovalResults text NULL,
Description varchar(255) NULL,
Status varchar(255) NULL,
LastFiledDate datetime NULL,
PatientBal money,
InsuranceBal money,
InsuranceName varchar(50) NULL
)
Jeff:
I see that most of the columns have the explicity NULL specification and that these two columns do not:
PatientBal money,
InsuranceBal money,
It is possible that you are in a situation in which column defaults have been designated as NOT NULL and that in this case explicit NULL specifications are necessary to allow nulls for these columns. In any case, the author is explicitly describing each of these columns as nullable. Try looking up ANSI_NULL_DFLT_ON and ANSI_NULL_DFLT_OFF in books online.
|||Another thing to check is SP_DBOPTION and look at the setting for 'ANSI null default'|||Null just means that the value is not known, (or that it is left blank intentionally is another common, though less right, usage). The programmer just wanted to make sure that if a value was NULL when data is being put into the temp tables it would not cause an error.
This is not really good practice, unless it is actually reasonable that values can be NULL, since NULLs really increases the complexity of working with data, but if the data allows nulls, then it is acceptable.
No comments:
Post a Comment