Click here to Skip to main content
14,930,079 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Linq, getting 3 of each record. Pin
Afzaal Ahmad Zeeshan24-Jul-17 10:36
mveAfzaal Ahmad Zeeshan24-Jul-17 10:36 
QuestionIF then ? Pin
patsq19-Jul-17 12:00
Memberpatsq19-Jul-17 12:00 
AnswerRe: IF then ? Pin
PIEBALDconsult19-Jul-17 13:01
professionalPIEBALDconsult19-Jul-17 13:01 
QuestionRe: IF then ? Pin
Richard MacCutchan19-Jul-17 21:51
mveRichard MacCutchan19-Jul-17 21:51 
AnswerRe: IF then ? Pin
patsq20-Jul-17 2:23
Memberpatsq20-Jul-17 2:23 
AnswerRe: IF then ? Pin
Richard Deeming20-Jul-17 1:36
mveRichard Deeming20-Jul-17 1:36 
GeneralRe: IF then ? Pin
Chris Quinn20-Jul-17 5:59
MemberChris Quinn20-Jul-17 5:59 
GeneralRe: IF then ? Pin
Richard Deeming20-Jul-17 6:50
mveRichard Deeming20-Jul-17 6:50 
Firstly, the second argument to Right should be 3, not 2.

And secondly, if the input number is 1000 or higher, that will strip the leading digits:
WITH cte (code) As
(
    SELECT 1
    UNION ALL SELECT 10
    UNION ALL SELECT 100
    UNION ALL SELECT 1000
    UNION ALL SELECT 10000
)
SELECT
    code,
    RIGHT('00' + CONVERT(varchar(10), code), 3)
FROM
    cte
;
Output:
1       001
10      010
100     100
1000    000
10000   000

It's not clear whether that's what the OP wants, but I doubt it. Smile | :)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: IF then ? Pin
Chris Quinn20-Jul-17 21:22
MemberChris Quinn20-Jul-17 21:22 
GeneralRe: IF then ? Pin
Richard Deeming21-Jul-17 0:15
mveRichard Deeming21-Jul-17 0:15 
AnswerRe: IF then ? Pin
Pradeep Magati11-Aug-17 2:58
MemberPradeep Magati11-Aug-17 2:58 
QuestionSetting values from a Pivot to 0? Pin
patsq18-Jul-17 4:55
Memberpatsq18-Jul-17 4:55 
AnswerRe: Setting values from a Pivot to 0? Pin
Chris Quinn18-Jul-17 5:01
MemberChris Quinn18-Jul-17 5:01 
GeneralRe: Setting values from a Pivot to 0? Pin
patsq18-Jul-17 5:08
Memberpatsq18-Jul-17 5:08 
GeneralRe: Setting values from a Pivot to 0? Pin
patsq18-Jul-17 5:24
Memberpatsq18-Jul-17 5:24 
QuestionPruning unused tables in a live database. Pin
mbb0113-Jul-17 2:43
Membermbb0113-Jul-17 2:43 
AnswerRe: Pruning unused tables in a live database. Pin
Mycroft Holmes13-Jul-17 13:31
professionalMycroft Holmes13-Jul-17 13:31 
AnswerRe: Pruning unused tables in a live database. Pin
Chris Quinn14-Jul-17 0:09
MemberChris Quinn14-Jul-17 0:09 
GeneralRe: Pruning unused tables in a live database. Pin
mbb0114-Jul-17 0:37
Membermbb0114-Jul-17 0:37 
GeneralRe: Pruning unused tables in a live database. Pin
Chris Quinn14-Jul-17 0:48
MemberChris Quinn14-Jul-17 0:48 
AnswerRe: Pruning unused tables in a live database. Pin
Eddy Vluggen14-Jul-17 2:39
professionalEddy Vluggen14-Jul-17 2:39 
AnswerRe: Pruning unused tables in a live database. Pin
Tim Carmichael14-Jul-17 8:57
MemberTim Carmichael14-Jul-17 8:57 
AnswerRe: Pruning unused tables in a live database. Pin
jschell15-Jul-17 9:33
Memberjschell15-Jul-17 9:33 
AnswerRe: Pruning unused tables in a live database. Pin
Mycroft Holmes15-Jul-17 14:43
professionalMycroft Holmes15-Jul-17 14:43 
GeneralRe: Pruning unused tables in a live database. Pin
Jörgen Andersson17-Jul-17 10:28
professionalJörgen Andersson17-Jul-17 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.