baskaran chellasamy

baskaran chellasamy

  • NA
  • 114
  • 147.3k

what is the query for updating null value with datetime value

Aug 24 2012 2:38 PM
Hi friends
 I have  a table which contain 5 columns .first three column  insert with value and 4 and 5 were set to null.

This is my stored procedure

alter procedure sp_excelforgeneralholidays(@filname nvarchar(max),@getdate datetime,@adminid int)
 as 
 declare @datavar nvarchar(max)
 declare @sql varchar(1000)
 --set @getdate=coalesce(@getdate,Getdate())
 set @datavar  = 'Excel 8.0;Database=' + @filname
 
 set nocount on
  begin
  --create table #temptable (Date date ,Day varchar(30),Reason varchar(100))
  set @sql ='insert into General_holydays_details(Date,Day,Reason) SELECT * FROM OPENROWSET(''Microsoft.jet.OLEDB.4.0'','''+@datavar+';HDR=YES'',''SELECT Date,Day,Reason FROM [Sheet1$]'')'
 
 
   exec (@sql)
   update General_holydays_details set createddatetime= @getdate where createddatetime=null
   update General_holydays_details set adminid=@adminid where adminid=null
  
 end
 
but when i executing this stored procedure, only excel file is  updated and createddatetime and adminid remain null value.
but i pass createddatetime value and adminid  to this stored procedure from my coding.
What is the problem please find out and help me

Answers (1)