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
 problem in setting date;

Author  Topic 

karthik_padbanaban
Constraint Violating Yak Guru

263 Posts

Posted - 2008-02-29 : 10:02:47
create table t(id int identity(1,1),name char(30),date datetime)

here the name is parsed out from a XML dataset., i want to set
getdate() to date coumn how can i set it for all rows for future inserts.,

i have given the procedure used.,


create PROCEDURE sp_sample_xml
@strXML ntext
AS
DECLARE @insert int
EXECUTE sp_xml_preparedocument @insert OUTPUT, @strXML

insert into t (SELECT * FROM OpenXML(@insert, '/NewDataSet/Table1', 2)
WITH
(
name char(30))
EXECUTE sp_xml_removedocument @insert


and exec sp_sample_xml '<NewDataSet>
<Table1><name>karthik</name></Table1></NewDataSet>

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-02-29 : 10:30:21
Set the date column to NOT NULL and then set GETDATE() as a default value for that column.

--
Lumbago
"SELECT Rum, Coke, Lime, Ice FROM bar WHERE ClosingTime = 'Late' AND FemaleMaleRatio > 4"
Go to Top of Page
   

- Advertisement -