Forum Replies Created

Viewing 15 posts - 6,331 through 6,345 (of 8,731 total)

  • RE: Case statement and group by

    This is untested, but it might give you an idea.

    SELECT MedRecNum,

    VisitID,

    VisitDate,

    MAX(CASE WHEN Answer <= 1 THEN Answer ELSE...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Interview Questions

    They don't seem extremely difficult. Unfortunately, many people will get them wrong.

    It seems like a nice test which will separate good from bad ones. However, on question 2, the queries...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Just curious, what are your SQL pet peeves ?

    SQL is delicious (6/5/2014)


    SQLRNNR (6/5/2014)

    Great. I love that excuse "It's the way we/I have always done it".

    That kind of excuse right there shows a base incompetence. Everything he...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How can I cut certain values in a strig to separate columns

    If you insert your information into a properly normalized table, the rest is easier.

    To do so, you can use the DelimitedSplit8K found in here: http://www.sqlservercentral.com/articles/Tally+Table/72993/

    And work with something like this:

    WITH...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: uses of string splitters

    Jeff Moden (6/4/2014)


    Luis Cazares (6/4/2014)


    sqldriver (6/4/2014)


    I didn't see this code in the initial capitalization thread. It's what I've been using happily for a couple years. Not sure how it compares...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    Hrhb.mail (6/4/2014)


    My magical crystal ball can't find the error. Could you share it with us?

    I need to add

    Where CatId=1 (or etc.)

    It causes an error

    Where are you adding your conditions?...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    My magical crystal ball can't find the error. Could you share it with us?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    rn is the column that I added with the value of ROW_NUMBER() OVER(PARTITION BY n.NewTitle ORDER BY n.NewId).

    If you need to know what ROW_NUMBER() does, read the following: http://technet.microsoft.com/en-us/library/ms186734(v=sql.105).aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    Basically, something like this?

    WITH CTE AS(

    SELECT ROW_NUMBER() OVER(PARTITION BY n.NewTitle ORDER BY n.NewId) rn,

    n.NewId,

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need Help to remove first word

    Just another option based on the fact that you're using 2 columns.

    WITH SampleData AS(

    SELECT 'This is a test' [address], 'This' strtype UNION ALL

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    Here's the whole code with no errors.

    What rules do we follow to get to your expected results?

    CREATE TABLE News(

    NewId bigint identity ,

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    Can you explain how do you get to that result?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Selecting Distinct From Multiple Tables

    Why are you joining all three tables if you only use tables from News?

    Could you post sample data and expected results? preferably in the form of INSERT statements.

    Here's how you're...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: insert into from multiple CTE

    dquirion78 (6/4/2014)


    Really

    So I probably need a new stored procedure !

    Maybe a new database or a new server. :hehe:

    We can't see what's going on, so we can't really help.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: dynamic pivot issue

    A stored procedure (yours) can call another stored procedure (sp_executesql) without a problem.

    Do you want to insert the results on a temp table? That would cause more difficulties but it...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 6,331 through 6,345 (of 8,731 total)