[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Sqlserver 2005 query syntax help

Posted on 2008-06-25
9
Medium Priority
?
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 60

Accepted Solution

by:
chapmandew earned 2000 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
 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

656 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