Forum Replies Created

Viewing 15 posts - 5,596 through 5,610 (of 8,731 total)

  • RE: Select multiple rows for column into single row, w/hard return

    You're right, the REPLACE will add a small amount of work to the server which might be unnoticeable in most cases. However, you shouldn't want to add unnecessary work 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: Select multiple rows for column into single row, w/hard return

    It works perfectly fine, the problem is that you're using 2 characters and stripping just one. You need to change the third parameter from the STUFF function.

    To get better and...

    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: CASE statement in where clause

    I'm leaving you with 3 options. The third might be the best, but you have to test them.

    declare @CODE varchar(32);

    declare @Work varchar(32);

    SET @Work = 'CASUAL'

    SET @CODE = 1000

    --Option 1

    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: Select multiple rows for column into single row, w/hard return

    This article explains what you need to do.

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    Be sure to use it only for display and don't store the concatenation in the database.

    Notes:

    You can use CHAR(10) + CHAR(13) for...

    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: Update based on CTE - can this be done in one step?

    In this case, you can update the CTE without problems. You just need to add the column you're updating.

    WITH cte AS (

    SELECT ID, patientid,admissiondate, dischargedate, lastdischarge,

    ...

    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: Help needed in resolving the below SQL

    Maybe you're looking for something like this:

    Select *

    from @new n

    WHERE invoice_id IN( SELECT i.invoice_id

    ...

    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: TSQL query help

    You can use a table valued constructor to simplify it

    select Username

    , (select max(choice) from (VALUES(column1 ), (column2), (column3), (column4),

    ...

    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: Creating View with where clause on one column

    Here's an option on how to do it.

    CREATE TABLE Customer(

    custid int,

    firstname varchar(50),

    lastname varchar(50),

    zipcode varchar(10))

    INSERT...

    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: Case in SQL

    That seems fine to me. An alternative could be:

    Case when Server_Excluded <> 'Yes' and Aged30 > 0 Then 'Green'

    when Server_Excluded <> 'Yes' and (Group= '' OR...

    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: Update rows

    Here are two options:

    CREATE TABLE Fun_Test( Somepath nvarchar( 50 ));

    INSERT INTO Fun_Test

    VALUES

    ( 'C:\QA\Documents\pdf1' ),

    ( 'C:\QA\Documents\pdf2'...

    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: Which Version of SQL Server should I Study?

    Grant Fritchey (10/28/2014)


    jeffgonzalez007 (10/28/2014)


    I think I'm going to start with SQL Server 2012. I'm not seeing to many books out there yet on the 2014 version. For 2012 I definitely...

    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: Advance script help. Second Saturday following month?

    Scott always tell me not to rely on date settings, but I keep doing it :-D. This is a different way to achieve it with a single script.

    CREATE TABLE TestDates(

    ...

    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: CROSS APPLY and Invalid Object Name

    rot-717018 (11/3/2010)


    BTW, changing the function to a TVF is not the best solution here as it is used all over the DB.

    Then create a new one and test for differences....

    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 Create View Script for all tables

    David,

    Note that this is a 2 year old thread. That said, your code can be improved to avoid errors if table or column names have spaces or other characters. You...

    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: Isnumeric function - ISNUMERIC('1E2')

    This is a possible option based on Scott's post. You might need to use additional validations and things can get really complex really quickly.

    SELECT

    TextID,

    ...

    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 - 5,596 through 5,610 (of 8,731 total)