Forum Replies Created

Viewing 15 posts - 2,386 through 2,400 (of 2,458 total)

  • RE: Practical used of database id

    Each database has a unique identifier. The system databases are always 1-4: Master: 1, TempDB: 2, model: 3, msdb: 4. You see get them all with:

    select database_id, name from sys.databases

    DBAs...

    "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: Query runs forever following database migration (2005 - 2008)

    My experience has been the same as Ryan's... Indexes not getting moved into prod and they would not be much help without rebuilding your stats as previously mentioned.

    Take a...

    "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 find a Query in all stored procedure

    Shadab Shah (9/5/2012)


    Hi Alan,

    I tried your solution also but 🙁 your solution is also not working.I tried to find out what was wrong with your query but as far...

    "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 find a Query in all stored procedure

    Eugene Elutin (9/5/2012)


    I can not see any points of trying to search for a specific query which can be implemented in unlimited number of ways. Eg. comments, white spaces, multi-lines,...

    "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 find a Query in all stored procedure

    This should do the trick (building on Robert's query and Luis's suggestion) :

    -- pass the query text as search string variable

    DECLARE @query varchar(1000)

    SET @query =' INSERT ...

    "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: Help with IF EXISTS and non existent column.

    I think this is what you are looking for (if not exactly, should be close enough):

    -- test table and test data

    --CREATE TABLE ssc_test

    --(

    --x int,

    --y int,

    --z varchar(20)

    --)

    --INSERT INTO ssc_test

    --SELECT 1,1,'old value'

    --UNION

    --SELECT...

    "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 Access to put data into SQL Server

    wayne_hudson3 (9/3/2012)


    Access will only display the first record from a table on a form.

    You will have to add a grid or some other mechanism to show all records.

    Just to clarify:...

    "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 Access to put data into SQL Server

    mrwillcostello (9/2/2012)


    ...I want to use this Access form (which contains all columns from 5 tables) to enter data into the SQL Server database. Please a little guidence would be greatly...

    "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: What do you use for creating admin utilities

    I concur 100% with grant. You can do a ton with TSQL, use Powershell for stuff you cant do with TSQL.

    Redgate tools are awesome too: The comparison utilities (schema...

    "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: Policy management

    I have used policies to ensure developers create objects in the correct schema. E.g. We want stored procs in environment X to go into schema xxx.

    "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: Loading the distinct rows in the destination table fromt the source table with some logic

    Sean Lange (8/30/2012)


    And it won't work if the OriginalAircraftNumber should be 847 and the FinalAircraftNumber should be 55. Also I am not quite sure the case statement will work exactly....

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

Viewing 15 posts - 2,386 through 2,400 (of 2,458 total)