Forum Replies Created

Viewing 15 posts - 8,056 through 8,070 (of 8,731 total)

  • RE: Using between in where clause from subquery

    Something like this?

    SELECT *

    FROM @Client cl

    WHERE EXISTS( SELECT 1

    FROM @ValidDates vd

    WHERE cl.ValidDate BETWEEN vd.StartDate AND vd.EndDate)

    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 rows with distinct values for a column.

    Lynn Pettis (6/12/2013)


    Luis Cazares (6/12/2013)


    As easy as

    SELECT UserID,

    MAX(Email) Email

    FROM MyTable

    If you need a specific email, you need to define the priority.

    Yep, easy except...

    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 rows with distinct values for a column.

    As easy as

    SELECT UserID,

    MAX(Email) Email

    FROM MyTable

    GROUP BY UserID --Edited post to add this line

    If you need a specific email, you need to define...

    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: Finding a word\acronym in a field

    Don. (6/12/2013)


    Thanks for the reply Luis.

    This script seems to do what I want with the demo data.

    Select top 100 *

    From CONTSUPP

    Where RECTYPE = 'C'

    AND ( CONTSUPREF...

    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: Finding a word\acronym in a field

    opc.three (6/12/2013)


    A CLR function that uses regular expressions, finding a "word" in a string that equals "LC" is a simple reg ex task, could also be a good option to...

    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: Converting nvarchar value to int

    A similar approach to Sean's iTVF.

    WITH Codes(code) AS(

    SELECT *

    ...

    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: Converting nvarchar value to int

    Maybe a recursive CTE can help you. Note that I'm including the sample data in a CTE and you might not need it when you apply the solution.

    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: Finding a word\acronym in a field

    That's because the first script is expecting a character after and a character before the LC, that's why I added trailing and leading spaces to the column. Try adding a...

    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: Finding a word\acronym in a field

    Everyone makes mistakes, so continue to participate in this forum, that way we all win and learn. 😉

    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: Finding a word\acronym in a field

    Deque (6/11/2013)


    Luis Cazares (6/11/2013)


    Learner44 (6/11/2013)


    I guess using wildcard character..

    like

    select * from student where studentname like 'LC%' ;

    is this the one what you are looking for?

    You have the right idea,...

    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: Finding a word\acronym in a field

    Sean Lange (6/11/2013)


    Or you could use the DelimitedSplit8K.

    I was going to suggest that as well 😀

    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: Finding a word\acronym in a field

    You might miss some desired results if you have other delimiters such as tabs or slashes.

    Be sure to add them between the brackets[] or to replace them with a space...

    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: Finding a word\acronym in a field

    Learner44 (6/11/2013)


    I guess using wildcard character..

    like

    select * from student where studentname like 'LC%' ;

    is this the one what you are looking for?

    You have the right idea, but you're not...

    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: inline table function

    Sean Lange (6/11/2013)


    sqlfriends (6/11/2013)


    we can also use table inline funciton for update statement, what is the syntax of that?

    No, you cannot update a function. A table valued function or a...

    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: inline table function

    You should use something like this

    SELECT spa.StudentID, spa.AddressID, itv.streetApt, ama.city, ama.state FROM stuPropertyAddress spa

    INNER JOIN dbo.addMasterAddress ama ON spa.addressID=ama.addressID

    CROSS apply dbo.FNC_GetStreetApt2(spa.StudentID) itv

    WHERE spa.StudentID = @studentID

    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 - 8,056 through 8,070 (of 8,731 total)