Forum Replies Created

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

  • RE: Where to start to learn XML with SQL Server

    Shadab Shah (11/11/2013)


    Hi Floks,

    I am trying to get my hands dirty with XML in SQL Server. I have tried MSDN and some other links which google suggested but i think...

    "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: Passing multiple values to a parameter in a stored produre

    Using DelimitedSplit8k (link in my signature), you could accept a delimited list like so:

    use tempdb;

    -- create tablea for demo

    IF OBJECT_ID('tempdb..tablea') IS NOT NULL drop table tablea;

    CREATE TABLE tablea(id int identity...

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

    timvil (11/11/2013)


    Thanks MM for your fast reply!

    However I didn’t get it to work. Maybe problem is in Column1 data type, it is ntext. I read somewhere that it couldn’t be...

    "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 query for ssrs report

    First, in the future try including your sample data like this:

    DECLARE @Store TABLE (s_yr int, s_mo tinyint, storeName varchar(10))

    DECLARE @Store_Sales TABLE (s_yr int, s_mo tinyint, storeName varchar(10), NumberOfSales int)

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

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