Forum Replies Created

Viewing 15 posts - 1,576 through 1,590 (of 2,458 total)

  • RE: Compare column in two tables

    Was stuck trying to do without cte/subquery... Using my sample data above:

    SELECT

    Col1 = ISNULL(a.name,b.name),

    Col2 = CASE ISNULL(a.name,'') WHEN '' THEN 'Table B' ELSE 'Table A' END

    FROM @tableA...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Compare column in two tables

    I was thinking....

    DECLARE @tableA TABLE (id int, name varchar(20));

    DECLARE @tableB TABLE (number int, name varchar(20));

    INSERT @tableA VALUES

    (101,'Dante'),

    (102,'Henry'),

    (103,'Harold'),

    (104,'Arnold');

    INSERT @tableB VALUES

    (102,'Dante'),

    (107,'Gilbert'),

    (109,'Harold'),

    (110,'Arnold'),

    (106,'Susan'),

    (112,'Marian');

    WITH names AS

    (

    SELECT a = a.name, b = b.name

    FROM @tableA...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SSIS Design Pattern - Staging Delimited Flat Files

    Great article Sam. Simple, to the point, easy read - well done sir!

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Any way to run an existing report back through the report Wizard?

    I could be wrong but I don't think so. To my knowledge the wizard is only available when you select "New Report".

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SQL Developers

    I was a DBA turned developer in 2010. I like administration but love development. If you are interested in a career as a SQL Developer you should consider getting up...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: please help, script not working getting msg 245

    sandy.alvarez (4/17/2015)


    BMC_CORE_BMC_BaseElement.Name, BMC_CORE_BMC_BaseElement.instanceid,

    BMC_CORE_BMC_BaseElement.reconciliationidentity

    FROM ARSystem.dbo.BMC_CORE_BMC_BaseElement BMC_CORE_BMC_BaseElement (NOLOCK)

    WHERE BMC_CORE_BMC_BaseElement.DatasetId='BMC.ASSET' AND

    BMC_CORE_BMC_BaseElement.createdate>='2014-01-01' AND

    BMC_CORE_BMC_BaseElement.createdate<='2014-12-31' AND (

    BMC_CORE_BMC_BaseElement.submitter='syl'OR

    BMC_CORE_BMC_BaseElement.submitter='salv'OR

    BMC_CORE_BMC_BaseElement.submitter='aj') order by 1

    You're missing a SELECT statement. Using NOLOCK removes the guarantee that...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: selective UNIONing

    dmodersk (4/17/2015)


    Wow thanks Alan! If I explain how I am interpreting this can you confirm if I am correct?

    First, a temp result set is created with all the rows...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Clustering and mirroring realtime interview questions

    I have not worked with SQL Server HA technologies (clustering, mirroring, replication, Log Shipping) since I was a DBA but I'll give you a few questions and the thinking behind...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Using XQuery modify 'replace value of' using a table column value as the new value

    Ok, I put together some DDL and sample data... I screwed up the aliases a little compared to what you have but this should still suffice. What you are doing...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Using XQuery modify 'replace value of' using a table column value as the new value

    DDL and sample data?

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Get just the .mdf and .ldf names not the path.

    Excellent, glad that worked for you.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: selective UNIONing

    With respect to records that are duplicated, let's say you only wanted the one with the most recent

    To get the records with the oldest Export date you could do...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: selective UNIONing

    I'm assuming you want your query results to include the Export date? and if so which record to you want keep (e.g. the one with the earliest Export date? oldest?)

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Get just the .mdf and .ldf names not the path.

    Nope, not that I am aware of. Not without using a sp_cmdshell or other non-tsql scripting tool

    What's wrong with this?

    SELECT

    DbName = db.name,

    FileType = CASE...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Find/Replace based on a table - strange results

    Katerine459 (4/16/2015)


    Alan.B - thanks for the DDL correction. Sorry about that; I totally forgot to indicate NULL/NOT NULL when setting up the table originally, so SQL Server assumed NULL for...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 1,576 through 1,590 (of 2,458 total)