Forum Replies Created

Viewing 15 posts - 2,581 through 2,595 (of 4,080 total)

  • RE: difference between INNER JOIN and Corealted subquery.

    If you have to retrieve values from a table, rather than simply test for existence, you probably should use a JOIN. Joins and correlated subqueries produce...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: round function behaviour

    In the first instance, it is probably interpreting your constant as a decimal or numeric type.

    declare @val decimal (6,2)

    set @val = 8493.65

    select round(@val,0)

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: building string in sp (as varchar) for use in select

    Hey Nick,

    CONVERT() gives you more control over the format of the output string than CAST().

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: get daterange from datepart(wk, datefield) grouping

    You're welcome, Marcus, and much success to you.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: building string in sp (as varchar) for use in select

    Nick, what you are seeing is an example of "parameterized" dynamic SQL. Instead of building the entire string, you can actually pass values into it as parameters....

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: building string in sp (as varchar) for use in select

    Nick, here is another article by Gail on the topic of SQL injection, which is a hacking technique used against SQL Servers. I'm including it because you really...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: building string in sp (as varchar) for use in select

    Okay... I see where you are going wrong. You can't just use a variable to build code and stick it in the middle of code like that, unless...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: building string in sp (as varchar) for use in select

    I would like to help but I'm not sure I understand your problem.

    What results are you getting currently? Error messages? Null...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Are the posted questions getting worse?

    I'm gonna Fedex Barry a load of frozen pork chops to throw at you guys for laughing at his pain.

    (Although I have heard that schadenfreude is...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: get daterange from datepart(wk, datefield) grouping

    Fair questions. Play around with this for a minute and you will see that it works for other dates than today. Explanations follow.

    -- edited to...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Many to Many - selecting records that don't include a word

    Guys, I encourage you to give CTEs a try. They act like views which exist only for the duration of a single query. But they read from...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: writing a query to search all columns at the same time(like a Wildcard search)

    You might also consider a view or cte that casts all your datetime columns as varchar. You realize of course that you can get no benefits from...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Using row results as dyamic columns?

    Actually, your solution is more commonly referred to as a crosstab, not a pivot.

    PIVOT is an SQL keyword in 2005 and up.

    Why are...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: get daterange from datepart(wk, datefield) grouping

    Does this help ?

    --

    select getdate() as today

    ,DATEPART(wk,getdate()) as WeekOfYear

    ,left(DATEADD(wk,DATEDIFF(wk,0,getdate()),-1),6)+ ' - '

    +left(DATEADD(wk,DATEDIFF(wk,0,getdate()),5),6) as weekRange

    --

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: select query

    You can also get it done with a LIKE in your where clause if you read up on the various wildcard patterns. But if you restrict it to an...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

Viewing 15 posts - 2,581 through 2,595 (of 4,080 total)