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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Changed Date

Author  Topic 

jdub_92
Starting Member

13 Posts

Posted - 2008-08-18 : 09:55:02
Hi All,

I'm new to this transact-sql, i just want to ask if how can i do this registration_date changed to getDate(), it's a one time run only,.

I have this two tables

tbl1(registration_date, active, status_id)
tbl2(status_id, auto_reg,)

i want to query all status_id from tbl1 and tbl2 that are active registration and change the registration_date to getDate() where auto_reg value is equal to one(1).

registration_date = date
active , where 0 = inactive and 1 = active
status_id (integer)
auto_reg, where 0 = manual reg and 1 = auto reg


thanks






jwill

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 09:57:59
[code]UPDATE t1
SET t1.registration_date=getdate()
from tbl1 t1
inner join tbl2 t2
on t2.status_id=t1.status_id
where t1.active=1
and t2.auto_reg=1[/code]
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-18 : 09:58:42
[code]
update t1
set registration_date = getdate()
from tbl1 t1 inner join tbl2 t2
on t1.status_id = t2.status_id
where t1.active = 1
and t2.auto_reg = 1
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jdub_92
Starting Member

13 Posts

Posted - 2008-08-18 : 10:43:16
thanks to you guys for the response,. i'll try this

jwill
Go to Top of Page
   

- Advertisement -