Forum Replies Created

Viewing 15 posts - 7,411 through 7,425 (of 8,731 total)

  • RE: calculate months days for start and end date (each month)

    Or simply use a Tally table:

    DECLARE @StartDatedate = '20130115',

    @EndDatedate = '20130307';

    WITH E1(N) 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: MySQL To SQL Server

    Import/Export wizard should perform better than inserts from openrowset.

    I understand that you already have the scripts to migrate but the wizard will create the SSIS package automatically and will preform...

    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 get The Rows Count for 'With' table before using it ??

    I just noticed the additional conditions on your WHERE clause that will always evaluate to false

    OR 1 = 0 OR 6 = 0

    Why do you even have 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: How to get The Rows Count for 'With' table before using it ??

    It's basically the same as using the subquery but using another CTE.

    WITH tmpTable AS (

    SELECT DISTINCT *,

    ROW_NUMBER() OVER ( ORDER BY InventorySys ) AS RowNumber

    FROM...

    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: Query Help

    Are you really suggesting to read the table 3 times instead of once?

    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: Query Help

    Something like this?

    WITH CTE AS(

    SELECT *,

    RANK() OVER(PARTITION BY cStudentID, CourseID ORDER BY CASE Termcode WHEN 'FG1' THEN 1 WHEN 'Q1' THEN 2 ELSE 3 END) rn

    FROM #TEMP

    )

    SELECT *

    FROM CTE...

    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 with subgrouping

    What exactly did you try? I'd rather help you to correct it than give you the whole answer to your problem. That way you can identify what you did wrong.

    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 with subgrouping

    You already have a post about this issue and I gave you a static example and a link with an article to make it dynamic. I could easily give 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: Update field based on condition

    You should have a table for Orders and another one for Orders details.

    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: Create table, how to set PK as MMYYYY?

    I'm not sure if I understand your requirement, but if you want to have a PK by month, you could create an additional CHECK constraint to validate for the first...

    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: Extract String from Column and place portions in additional columns

    I'm not sure if SQL Server will be efficient on managing this, but it seems that this code should do the work. Note that I had to cast the text...

    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: Return query with concatenating values.

    For explanation on the code that Keith posted, read the following article and post back if you have any more questions.

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

    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: Comibing columns with null values as one row

    Jim1234 (11/15/2013)


    SELECT EMPID,MAX(EMPNAME),MAX(SALARY),MAX(DEPARTID) FROM EMPLOYEE_TEST

    GROUP BY EMPID,DEPARTID

    Try removing DEPARTID from your GROUP BY clause.

    I agree with Steve, you need to review why do you have bad data and correct 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
  • RE: SQL trigger

    Could you post DDL, sample data in the form of INSERT INTO statements and expected results based on that sample data.

    I'm not sure if you have the best design 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: Pivot question with multiple columns and grouping

    I can help you with the basic code, however, you need to work on doing it dynamic as it involves more work and time which I don't have.

    For dynamic code...

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