Solved

Sqlserver 2005 query syntax help

Posted on 2008-06-25
9
199 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
 
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now