Forum Replies Created

Viewing 15 posts - 316 through 330 (of 1,082 total)

  • RE: How to apply SUM function multiple times on a column?

    does my solution not work???

    I'll test it with a million rows and see what happens...

    OH and you haven't given us an example of a different start position?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: How to apply SUM function multiple times on a column?

    Here is a solution that doesn't use a loop.

    It uses a tally table.

    The only thing missing from the query is that I'm not 100% sure how the StartPostion comes into...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    at least you not getting an error now.

    So all that needs to be is to make sure your data is correct that you searching for 🙂

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    Sorry was thinking of something else.

    If you change the EXEC @sql to :

    EXEC (@SQL)

    It should work

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    cool I'll wait for your reply.

    It might also be funny data in your table.

    but I can't see any columns being used for the dynamic build...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    cool please could you post the full CREATE PROCEDURE code.

    Sorry to be a pain, but something is missing here...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    where is the code that sets the variables and declares the variables???

    I need a script I can copy directly from here and paste into a SSMS window and run to...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    Ok.

    But you still haven't post the exact script that you are running...

    We can't help if we don't know the values of the variables

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Special Character in select statement.

    nah it's cool I been editing my posts 🙂

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Special Character in select statement.

    mmm you basically just wrapping you " in Quotes but it seems wierd cause there are 4 of them I know.

    Sorry I'm not 100% sure how to explain this...

    But basically...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Special Character in select statement.

    oh sorry about that.

    try this

    select left([name], 1) from table1 where left([name], 1) ="""" and right([name], 1) =""""

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    both of the posting that I have made run 100% and the only thing I have changed was adding the )

    So I think the actually variable values that are being...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    what about if you run this?

    CREATE TABLE InsSales

    (

    region VARCHAR(100),

    SaleYear INT,

    salesPerson VARCHAR(100),

    SalesMonth INT,

    TotalSales INT )

    GO

    DECLARE @CYear VARCHAR(100)

    DECLARE @PYear VARCHAR(100)

    DECLARE @SalesPerson VARCHAR(100)

    DECLARE @Salesmonth VARCHAR(100)

    SELECT

    @CYear = 2009,

    @PYear = 2008,

    @SalesPerson = 'Smith',

    @Salesmonth =...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Special Character in select statement.

    🙂

    Thanks

    You need to use single quotes around the double quotes

    DECLARE @table1 TABLE

    ([name] VARCHAR(100))

    INSERT INTO @table1

    SELECT '"STICHTING WERELDHULP-BELGIE"'

    select left([name], 1) from @table1 where left([name], 1) ='"' and right([name], 1) ='"'

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: can anyone see anything wrong with this query?

    running this code gives no errors.

    CREATE TABLE InsSales

    (

    region VARCHAR(100),

    SaleYear INT,

    salesPerson VARCHAR(100),

    SalesMonth INT,

    TotalSales INT )

    SELECT x.SaleYear, x.TotalSales

    FROM (SELECT SaleYear,

    TotalSales =...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life

Viewing 15 posts - 316 through 330 (of 1,082 total)