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
 ADD New Column with my text

Author  Topic 

Amber_Deslaurier
Starting Member

40 Posts

Posted - 2010-05-29 : 14:04:45
Hi!

I have an existing query and I would like to add a new Column called WDate and to have "2010-05-29" added to every line that has output...

is this correct?

"2010-05-29" WDate,

Thanks!

Amber-

Sachin.Nand

2937 Posts

Posted - 2010-05-29 : 16:46:30
Can you please elaborate more what exactly do you want?

PBUH
Go to Top of Page

jason_heckenkamp
Starting Member

1 Post

Posted - 2010-05-29 : 19:05:38
Hi Amber,

Let's say your query looks like this:

SELECT
Field1,
Field2,
Field3
FROM MyTable
WHERE 1=1

You would do this to meet your needs:

SELECT
Field1,
Field2,
Field3,
'2010-05-29' AS WDate
FROM MyTable
WHERE 1=1

Hope this helps.

-Jason
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-31 : 03:55:22
Also if you want to make it datetime, cast it to datetime

cast('20100529' as datetime) AS WDate

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-05-31 : 04:10:46
... and leave the hyphens out, as Madhi demonstrates.
Go to Top of Page

Amber_Deslaurier
Starting Member

40 Posts

Posted - 2010-06-17 : 22:29:21
Thanks guys!
Go to Top of Page
   

- Advertisement -