Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


PIVOT UNPIVOT IN SQL2005


PIVOT UNPIVOT IN SQL2005

Author
Message
Shintu
Shintu
SSC Rookie
SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)

Group: General Forum Members
Points: 47 Visits: 64
Thank U so so much Cold Coffee,And very sorry that I am responding today as I had left my office at that moment.

May I know your name please, as U can guess I am subhro from India.
Can u just explain what is the idea behind this query you have send?



Thanks

Subhro
Shintu
Shintu
SSC Rookie
SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)

Group: General Forum Members
Points: 47 Visits: 64
Thanks for your assistance

Cheers

Subhro
ColdCoffee
ColdCoffee
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2317 Visits: 5545
Subhro,

There is a REPLACE operation followed by the CAST in my code.

REPLACE will replace a set of characters , with a replacement value , on the string in which you want a part of it to be replaced. For syntax, kindly refer to the link i provided in the previous post!

In our case, we dont need cnt from the OrderYear column.

So, we used REPLACE('cnt2007', 'cnt', '') ;
This implies, in the string 'cnt2007', if u find 'cnt' in it, replace it with '' (a empty string). Thus, at the end of this code, your new string will be '2007'; As we need that to be INT, we cast '2007' to INT.

Hope this information helps you! If you further need assistance , let us know here!

I am Prasanna, from India! Glad to help you and meet you in the forums!

Cheers!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search