Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update date column with datatype datetime

Author  Topic 

arthiasha
Starting Member

40 Posts

Posted - 2012-07-04 : 07:27:38
i want to update date column as NULL with its already existing datatype as datetime.
when i update the error displayed as 'cannot insert the value NULL in start_date column. the table task_schedule does not allow nulls'
please send me the query....

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-04 : 07:33:28
You need to change the column to allow nulls if you want to update it to null.

alter table task_schedule alter column start_date datetime null

Check the current column to see that there isn't anything else like a default on it

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-04 : 19:26:02
first check why it was declared as NOT NULL in first place. It may be that business logic forces it to have a value always. I would suggest doing these types only after doing sufficient impact analysis to understand dependencies and relevance of involved field(s)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arthiasha
Starting Member

40 Posts

Posted - 2012-07-10 : 00:37:47
Thanks a lot...
I need a query for the table 'task_schedule' where the columns are...

company_id varchar(12),
project_id varchar(20)
sub_project_id varchar(20),null
unique_id int
task_id int
wbs_id varchar(20),null
task_type varchar(1),null
task_description varchar(255),null
sch_start_date datetime, null
sch_finish_date datetime,null
plan_duration int,null
Plan_duration_uom varchar(2)
task_status varchar(2)
predecessors varchar(255),null
successors varchar(255),null
resources varchar(255),null
act_start_date datetime,null
act_finish_date datetime,null
projected_start_date datetime,null
projected_finish_date datetime,null
projected_duration int,null
projected_duration_uom varchar(2),
status_date datetime,null
remaining_duration int,null
remaining_duration_uom varchar(2),null
completion_percentage tinyint,null
actual_duration int,null
actual_duration_uom varchar(2),null
task_owner varchar(7),null
equipment_code nvarchar(15),null
asset_code nvarchar(15),null
all_predecessors_complete_ind varchar(1),null
last_update_id varchar(20),null
last_update_timestamp timestamp



These are the column names of the table 'task_schedule' and i wanted to update the columns to NULL 'task_status','sch_start_date','sch_finish_date','act_start_date','act_finish_date','projected_start_date','projected_finish_date','projected_duration','status_date'
where the 'task_status' is 'NS'

Please send me the query

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-10 : 10:29:39
have a look at syntax of UPDATE statement in MSDN. Its straight forward requirement and you shouldnt expect spoonfed answers for this. Make a try and post if you face any issues. We're not going to spoonfeed you with your assignment question solution

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -