Forum Replies Created

Viewing 15 posts - 2,311 through 2,325 (of 2,462 total)

  • RE: "USE DATABASE" in stored procedure

    Danzz (1/9/2013)


    Thanks for all your help..

    1)I am not looking databases_files in the Out put.

    Example:

    DBA_Databasename_Data

    DBA_Databasename_Log

    2)I am looking for "Use Database" in the our put.

    Example:

    USE DBA_Databasename

    AJB:

    3) I used sys.database_files in...

    "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: Better Way to Perform this Query

    AndrewSQLDBA (1/9/2013)


    Hello Everyone

    I hope that everyone is having a very good day.

    I need to write a query to select row counts, but this seems like a lot of scanning 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: "USE DATABASE" in stored procedure

    Danzz (1/9/2013)


    Thanks for your reply Alan

    I tried couple of ways, It did not work out

    create table ##permission_info (id int primary key identity, information varchar(8000))

    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: Question about Optional Parameters in Stored Procedures

    Jacob Pressures (1/9/2013)


    Ok thanks for the info. Right now I'm trying to avoid D-SQL until i learn more about it.

    The TVP seems, at least in my head, like an alternative...

    "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: "USE DATABASE" in stored procedure

    Add USE statement to a proc (using DSQL):

    CREATE PROC xxx AS

    BEGIN

    DECLARE @sql varchar(100)='USE tempdb; SELECT * FROM sys.database_files;'

    EXEC(@sql);

    SET @sql='USE master; SELECT * FROM sys.database_files;'

    EXEC(@sql);

    END

    You can also accomplish this using the...

    "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: Question about Optional Parameters in Stored Procedures

    I can't speak to TVPs but I use this technique to create a default value in stored procedures and functions have seen it used quite often.

    I have always been...

    "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: Double Counting and Sign Reversals

    Great article Dwain! It also inspired me to read the N-Tuple article which I liked.

    It’s almost a shame (not really! J) that I no longer support Accounting applications because...

    "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: editing SQL Server 2008 query output file in linux

    NP. πŸ™‚

    "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: Divide N object to N person

    Edit: misread ddl. Said something stupid.

    I tried to solve this and failed. Well done Dwain C.

    "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: editing SQL Server 2008 query output file in linux

    There are some nuances I wont cover here but should work or at least get you started.

    To export a query from SQL Server to comma delimited CSV file

    1) Right-click...

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

    On the other side... I have never run REPAIR_ALLOW_DATA_LOSS.

    "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: Quert regarding getting the results based on months.

    This is not the most elegant or optimized approach but this will get you the result set that you are looking for...

    --Parameter

    DECLARE @topMonth int=3;

    --if a valid month is not...

    "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: ''=0 ?!?!

    dwain.c (12/17/2012)


    If you think those "typos" that pass SQL Server's parser seem weird, try this one:

    SELECT 7+$

    Thanks for the post dwain. That's really odd too; I would never think to...

    "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: Retrieve second of three values separated by spaces

    Another way:

    DECLARE @spitme TABLE (Item varchar(40));

    INSERT @spitme VALUES ('HEYE-B Euro-IPA 69793'), ('HEYE-B RFE-IPA 70940');

    SELECT SUBSTRING(Item, CHARINDEX(' ',Item)+1, LEN(Item)-(CHARINDEX(' ',Item)+CHARINDEX(' ',REVERSE(Item))))

    FROM @spitme

    Fun.

    "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: Retrieve second of three values separated by spaces

    Using Jeff Moden's splitter[/url] you can do this...

    DECLARE @spitme TABLE (Item varchar(40));

    INSERT @spitme VALUES ('HEYE-B Euro-IPA 69793'), ('HEYE-B RFE-IPA 70940');

    SELECT s.Item

    FROM @spitme val

    CROSS APPLY test.[dbo].[DelimitedSplit8K](val.Item,' ') s

    WHERE ItemNumber = 2

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