Forum Replies Created

Viewing 15 posts - 4,126 through 4,140 (of 8,731 total)

  • RE: Pivot, NestedPivot, unPivot?

    If you can query the specific milestones, you can limit them.

    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 me with the SYNTAX for the DELETE statement

    If Gender is a non nullable column, it will work.

    I'd usually go for something like this:

    Delete T

    FROM Event_Temp_Lead_Screen T

    WHERE NOT EXISTS( SELECT 1 FROM member M WHERE ...

    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: PHP to SQL

    Variable lose scope inside the EXECUTE(), you would need to send them as parameters using sp_executesql or concatenate them in the string as I did.

    Generally speaking, using parameters with sp_executesql...

    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: Pivot, NestedPivot, unPivot?

    YB already showed an example on how you should post sample data. For instructions on how to do it in a simple way, visit the following articles for 2 options:

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/

    Here...

    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: Hresult: 0x80004005 Description: "The metadata could not be determined because the statements not compatible with the statement

    The problem is that DB_Type and DB_ENV don't have a data type assigned. Every column in your queries needs a data type defined.

    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: PHP to SQL

    Let's go step by step.

    The following code generates 10 rows. I don't care about the contents, so it's a simple column with zeros.

    SELECT n FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n)

    Then I use a cross...

    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: Hresult: 0x80004005 Description: "The metadata could not be determined because the statements not compatible with the statement

    Here's a different idea. Remove the IF

    SELECT @@servername AS Instance,

    b.database_name...

    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 to convert the string date format to datetime using Derived column

    Do you seriously have the dates stored as strings like that? Or that's the display used? Dates should be treated as dates. SSIS can identify a date/time value in the...

    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: I think this is a Check Constraint question.

    You can also define the columns as the Primary Key.

    ALTER TABLE OrderDetails

    ADD CONSTRAINT PK_OrderDetails PRIMARY KEY (InvoiceID, LineitemNumber);

    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: Difficulty with aggregating values that match the aggregate result

    Here are 2 options to get your desired results. There might be others available but these where the first I could think of.

    --Option 1

    SELECT m.keyvalue,

    otherdata,...

    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: Hresult: 0x80004005 Description: "The metadata could not be determined because the statements not compatible with the statement

    Try by casting the literals in your second select statement. Another good idea is to use EXISTS for your condition.

    IF EXISTS(select 1 from msdb..backupset)

    BEGIN

    select @@servername as...

    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: Deciphering a job description

    Development/Testing/QA/Production

    I'm not sure about the T, but the letters define the different environments used. The RTO and RPO will differ from environment to environment.

    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: Seems like a job for a window function, but...

    You'll need another ROW_NUMBER function.

    WITH CTE AS(

    SELECT *,

    ROW_NUMBER() OVER ( ORDER BY DateTimePressed) - ROW_NUMBER() OVER ( PARTITION...

    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: PHP to SQL

    Ok, be sure to understand what's going on in here and ask any questions that you might have. You can't blame me if something goes wrong and you're not sure...

    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: Seems like a job for a window function, but...

    This problem and its solution is explained in here: http://www.sqlservercentral.com/articles/T-SQL/71550/

    The only difference is that the article uses days instead of minutes.

    CREATE TABLE #RedButtonPress(

    Name ...

    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 - 4,126 through 4,140 (of 8,731 total)