Forum Replies Created

Viewing 15 posts - 2,401 through 2,415 (of 2,462 total)

  • RE: Loading the distinct rows in the destination table fromt the source table with some logic

    Based on your sample data and DLL this should work:

    SELECTFlightDate,

    FlightNumber,

    ScheduleOrder,

    MIN(AircraftNumber) OriginalAircraftNumber,

    MAX(AircraftNumber) FinalAircraftNumber,

    ChangeOfAircraftIndicator=

    CASE

    WHEN COUNT(ScheduleOrder)=1 THEN 'N' ELSE 'Y'

    END

    FROM [dbo].[DailySchedule]

    GROUP BY FlightDate, FlightNumber, ScheduleOrder

    ORDER BY FlightDate, FlightNumber, ScheduleOrder

    This will...

    "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: How to get the SP's based on certain search string

    also, if the stored procs are spread accross multiple databases you could use this:

    -- create temp table for result set

    IF OBJECT_ID('tempdb..#sprocSearchResults') IS NOT NULL

    DROP TABLE #sprocSearchResults

    CREATE TABLE #sprocSearchResults (StoredProc...

    "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: How to get the SP's based on certain search string

    Someone beet me to it but you can also use:

    SELECT DB_NAME()+'.'+ROUTINE_SCHEMA+'.'+ROUTINE_NAME [Stored Proc]

    FROM INFORMATION_SCHEMA.ROUTINES

    WHERE CHARINDEX('@prmSorted',ROUTINE_DEFINITION)<>0

    AND ROUTINE_TYPE='PROCEDURE'

    "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: The Best SQL Server Tutorials

    The stairways are great. I also use Microsoft E-Learning; there is ton's of free stuff there.

    "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 give query for below output

    Expanding on mohankollu's solution... You can get this returned as text in the result set with

    DECLARE @aa table(col varchar(20))

    insert into @aa values('100'),('200'),('300'),('400'),('500');

    WITH t(col) AS

    (

    SELECT col+','

    FROM @aa 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

  • RE: Subscriber DB size is growing larger than Publisher

    ashwinboinala (8/21/2012)


    hi all,

    i have an issue Subscriber DB size is growing larger than Publisher , publisher db is 21gb , but subscriber db is 72 gb i am using...

    "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: how to put together or exclude the result from two or more select query

    There are many, many ways to procuce each result set. For the first one you could use UNION (not UNION ALL).

    "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: high reads

    Can you post some ddl? how many rows are in these tables? It would be helpful to understand your indexes, contraints, etc.

    "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: Backup size

    GilaMonster (8/20/2012)


    Actually it probably will be.

    That query returns the total size of the DB files. A backup does not back up the entire file, just the used portion of...

    "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: Backup size

    This will tell you the minimum size (the size of your MDF and NDF files). The backup, unless compressed, will never be less than this.

    USE {myDB};

    SELECT SUM(size/128) AS mb...

    "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: Full vs Transaction Log Backup

    Transaction log maintenance can be a drag. The stairway about this topic is great.

    "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 server table on a PC

    Beginner2012 (6/8/2012)


    Hello,

    can we create a SQL server table on a PC based on a query on the sql server ?

    Thank you

    edited... Misunderstood your question.

    ... Perhaps some more detail would...

    "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: Error Handling: TRY...CATCH

    TRY/CATCH is traditionally used more for stuff like this:

    SET NOCOUNT ON;

    DECLARE @pos TABLE (sale_id varchar(4), product_id int)

    DECLARE @err varchar(200)

    BEGIN TRY

    INSERT INTO @pos VALUES ('ccc', 'a')

    END TRY

    BEGIN CATCH

    --...

    "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: Just starting first job - SSIS & SSAS

    Read, read, read: books online, a web page or blog...

    Practice, practice, practice...

    Microsoft E-learning, plenty of free stuff there. Go to products > SQL Server. There's tons of free...

    "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: Landing The First SQL Job....

    First, being a DBA and a SQL developer is an excellent experience on bothaccounts. This is also a great time as there is a HUGE shortage of DBAs and Database...

    "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 - 2,401 through 2,415 (of 2,462 total)