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.
| Author |
Topic |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2010-07-24 : 01:11:24
|
| Dear All,I am having following queary and output,SELECT PI.REVENUE AS SECOND_REVENUE FROM SA.A_PERFORMANCEINVESTIGATION PIINNER JOIN SA.D_DATE DT ON PI.DATEID = DT.DATE_ID WHERE TO_CHAR(DT.FULL_DATE,'DD/MM/YYYY') = (select TO_CHAR(sysdate-1,'DD/MM/YYYY') from dual) Output:SECOND_REVENUE120978I want output as follows, means i want to column name as current date. Output:24-07-2010120978 |
|
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2010-07-24 : 02:34:30
|
try this:declare @string char(30)set @string = quotename(replace(convert(varchar(10),getdate(),102),'.','_'))print @stringdeclare @sql nvarchar(200)set @sql = 'select 1234 as ' +@stringexec sp_executesql @sql |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2010-07-24 : 02:44:14
|
| Dear slimt_slimt,But i am using single queary, i am not using store procedure.Is it possible with single queary.thnks |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-07-24 : 03:41:39
|
| Whatever you do in stored procedure you can use it inline.As if you are passing some parameters to procedure You will have to declare it and have to set its value at the top of Stored procedure code.so can use above code inline definitely..Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-24 : 03:42:06
|
are you using SQL Server or Oracle ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2010-07-24 : 04:49:03
|
| Dear khtan,I am using Oracle 10g.thanks |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-24 : 05:57:36
|
quote: Originally posted by hspatil31 Dear khtan,I am using Oracle 10g.thanks
Then you should be posting at a Oracle forum. You might have not aware that that you have posted in "General SQL Server Forum" - "New to SQL Server Programming". SQLTeam.com is on Microsoft SQL Server KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-07-26 : 08:57:26
|
| Post your question at www.orafaq.comMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|