All of Query was successfully tested and running well on Microsoft SQL Server 2008

Kamis, 23 Agustus 2012

declare in sql

declare @currDate1 datetime
declare @currDate2 datetime
declare @Schedule1 nvarchar(20)
declare @Schedule2 nvarchar(20)

set @currDate1='2012-08-24 06:28:41.420'
set @currDate2='2012-08-24 14:28:41.420'
set @Schedule1='I go to school'  
set @Schedule2='I go to zoo'

select (@currDate1)currDate1,(@Schedule1)Schedule1,(@currDate2)currDate2,(@Schedule2)Schedule2

currDate1                  Schedule1         currDate2                  Schedule2
2012-08-24 06:28:41.420    I go to school    2012-08-24 14:28:41.420    I go to zoo

Query can be modified as below
select (@currDate1)schedule_date,(@Schedule1)schedule_activity union  
select (@currDate2)schedule_date,(@Schedule2)schedule_activity

schedule_date              schedule_activity
2012-08-24 06:28:41.420    I go to school
2012-08-24 14:28:41.420    I go to zoo

Tidak ada komentar:

Posting Komentar