SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update date column with datatype datetime
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

arthiasha
Starting Member

India
40 Posts

Posted - 07/04/2012 :  07:27:38  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 07/04/2012 :  07:33:28  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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

India
47157 Posts

Posted - 07/04/2012 :  19:26:02  Show Profile  Reply with Quote
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/


Edited by - visakh16 on 07/04/2012 19:26:23
Go to Top of Page

arthiasha
Starting Member

India
40 Posts

Posted - 07/10/2012 :  00:37:47  Show Profile  Reply with Quote
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

India
47157 Posts

Posted - 07/10/2012 :  10:29:39  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000