Forum Replies Created

Viewing 15 posts - 2,041 through 2,055 (of 2,458 total)

  • RE: use cte instesd of while and temp table

    elham_azizi_62 (11/11/2013)


    ...now i want to use cte instead of while and temp table?is it possible?if yes,how can i do this?

    thanks

    You can do this using a recursive CTE like so:

    WITH...

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

    I would also recommend: http://en.wikipedia.org/wiki/ACID.

    "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: XML Export File

    I think this will get you what you need:

    DECLARE @Result varchar(1000);

    WITH x(xx) AS (select * from Xml_Export listing for xml auto ,elements ,ROOT('Listings'))

    SELECT @Result='<?xml version="1.0" encoding="UTF-8" ?>'+xx

    FROM x

    --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 bring in more than one column from left table in a CURSOR/dynamic sql query

    dwain.c (11/6/2013)


    Alan.B (11/6/2013)


    You could do something like this (I changed @name to @names):

    DECLARE @names varchar(max);

    WITH names(n) AS

    (

    SELECT Name

    FROM dbo.iNamesExcel$

    FOR XML PATH('')

    )

    SELECT @names=CHAR(39)+LEFT(n,LEN(n)-1)+CHAR(39)

    FROM names

    Then, in your DSQL change your...

    "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: udf very slow?

    Almost there... This was the first draft and, though it is processing all your variables, I made a mistake(s) somewhere in my formulas; I had very limited time. The reason...

    "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: udf very slow?

    Eric Mamet (11/7/2013)


    Hi everyone, sorry for being so slow but I just did not have time to go through the article before...

    Yes, it is very interesting and intriguing but...

    "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: udf very slow?

    I am pretty sure that you can turn that into an inline table valued function. It isn't something I can do quickly but I will take a shot at this...

    "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 bring in more than one column from left table in a CURSOR/dynamic sql query

    You could do something like this (I changed @name to @names):

    DECLARE @names varchar(max);

    WITH names(n) AS

    (

    SELECT Name

    FROM dbo.iNamesExcel$

    FOR XML PATH('')

    )

    SELECT @names=CHAR(39)+LEFT(n,LEN(n)-1)+CHAR(39)

    FROM names

    Then, in your DSQL change your and displayName...

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

    I would add that you can also do it like this:

    --sample data

    SELECT * INTO #test

    FROM (VALUES (1,'blah AAA'),(2,'bbb bbb bbb'),(3,'AAA ccc')) t(id,val);

    SELECT * FROM #test;

    WITH your_table AS

    (

    SELECT * FROM...

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

    SQLSteve (11/6/2013)


    Still stuck on a solution for this if anybody could assist

    I'm short on time here but will help get you started. Nothing you are doing sounds too difficult 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: Phone number question - detecting and replacing

    matt6749 (9/23/2013)


    Hello,

    I have a website/database app with a text column that stores a user's bio where users are not allowed to embed their phone number (e.g. similar to a dating...

    "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: Phone number question - detecting and replacing

    dwain.c (9/23/2013)


    matt6749 (9/23/2013)


    I respect your wish to have structured forum dialog, but it appears that, for this relatively simple question, helpful suggestions are possible without INSERT INTO and CREATE TABLE...

    "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: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Thanks Dwain!

    "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: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Solomon Rutzky (11/5/2013)


    Alan.B (11/5/2013)


    With your question about reasonableness, it's up to you. If performance wasn't an issue, why maintain two different functions? If it does matter, you can create 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: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Thanks!

    With your question about reasonableness, it's up to you. If performance wasn't an issue, why maintain two different functions? If it does matter, you can create a calculated column on...

    "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,041 through 2,055 (of 2,458 total)