To start sql output frm the middle of the page

  • Hi,

    I have a sql query

    ###########################

    selectcount(tot_files) (title 'Number of files=')

    from month_test ;

    #########################

    the output will be

    'Number of files= 4

    ########################

    the output 4 is coming after 12 spaces..... is there any way to get that number immediately after '=' sign.

  • Cast/Convert the string to varchar.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Can u provide me the solution

  • declare @a varchar(100)

    set @a = 'Number of files=4'

    select substring(@a, 17, len(@a))

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

  • gnaneshs (1/6/2011)


    Can u provide me the solution

    I'm not sure about that "title" bit you're using. Using the structure I'm accustomed to, it might look like:

    declare @Title varchar(100) = 'Number of files=';

    select @Title = @Title + cast(count(*) as varchar(100))

    from month_test;

    print @Title;

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • toddasd (1/6/2011)


    declare @a varchar(100)

    set @a = 'Number of files=4'

    select substring(@a, 17, len(@a))

    :blink:

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • gnaneshs (1/6/2011)


    Can u provide me the solution

    GSquared gave you a correct solution but do you understand it? If not, I strongly recommend that you lookup the CAST function, the VARCHAR datatype, and the concatenation operator of "+" in Books Online. Assuming by your question that you're an absolute newbie with SQL Server, "Books Online" is the help system that comes with SQL Server.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (1/6/2011)


    toddasd (1/6/2011)


    declare @a varchar(100)

    set @a = 'Number of files=4'

    select substring(@a, 17, len(@a))

    :blink:

    To me, looks like he wanted the "4" from the string. So, you know, taking a shot in the dark at a black cat.

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

  • toddasd (1/6/2011)


    Jeff Moden (1/6/2011)


    toddasd (1/6/2011)


    declare @a varchar(100)

    set @a = 'Number of files=4'

    select substring(@a, 17, len(@a))

    :blink:

    To me, looks like he wanted the "4" from the string. So, you know, taking a shot in the dark at a black cat.

    BWAA-HAAA!!!... understood. I sometimes take the same shot without the benefit of moonlight. 😛

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply