Solved

Sqlserver 2005 query syntax help

Posted on 2008-06-25
9
201 Views
Last Modified: 2010-04-21
I have
+ convert(varchar(10), getdate(), 112)

which is part of a concantonated query

it yields:

20080625

for its piece

I need it to show:

062508

Thanks in advance
0
Comment
Question by:MyDanes
  • 4
  • 3
9 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 21867344

select replace(convert(varchar(10), getdate(),10),'-','')
0
 
LVL 8

Expert Comment

by:sbagireddi
ID: 21867364
SELECT REPLACE (CONVERT(varchar(10),getdate(),1),'/','')
0
 

Author Comment

by:MyDanes
ID: 21867399
Ok that did not work I got an error - I should have put the entire section which is:

select top 100 percent '2',right('0000000000' + cast(payment_id as varchar(10)),10) +
       right('0000000000' + replace(cast(amount as varchar(10)),'.',''),10) + '355008765102873' + convert(varchar(10), getdate(),10),'-','') as result
from CASHMGMT_PAYMENT

ONLY need to fix the getdate part so my output for the getdate portion shows:
062508

0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 21867433
you forgot the 2nd replace:



select top 100 percent '2',right('0000000000' + cast(payment_id as varchar(10)),10) +
       right('0000000000' + replace(cast(amount as varchar(10)),'.',''),10) + '355008765102873' + replace(convert(varchar(10), getdate(),10),'-','') as result
from CASHMGMT_PAYMENT
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 21867456
huh?  why did you pick that one over mine?  your syntax was wrong in your 2nd post.
0
 

Author Comment

by:MyDanes
ID: 21867527
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 21867545
OK.  You just had me confused....thought I had answered something wrong.  :)
0
 

Author Closing Comment

by:MyDanes
ID: 31470646
Thanks Chapmando and sorry for the trouble
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question