Forum Replies Created

Viewing 15 posts - 2,431 through 2,445 (of 2,462 total)

  • RE: Removing tags stored in a ntext field

    Oky Doky.

    Just got back from vacation and wanted to get to this ASAP. I am not optimizing this query, just getting the desired results for now.

    First, no UDF needed....

    "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: Get running total in the following query

    ChrisM@home (7/20/2012)


    XMLSQLNinja (7/18/2012)


    ...

    There are other ways to do this but using recursion is generally the fastest.

    Recursion is the third fastest; CLR > "Quirky Update" > rCTE > cursor > triangular...

    "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: Get running total in the following query

    Just got back from vacation and wanted to address this one first...

    I must be missing something but I don't see how that recursive CTE (as much as I like...

    "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: Database update from web page

    First thought was that we would connect to current db and do updates directly (validating fields before update).

    Good Grief! First and foremost - NEVER do that. As a DBA,...

    "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: Need help in T-sql to get the Last Year's first 4 week sales data

    First, by "count of" sales I assume you mean SUM of sales. Otherwise we'd be looking at a result set a little more like:

    WeekEndDate SalesTotal

    2011-01-07 1

    2011-01-14 1

    2011-01-21 1

    2011-01-28 1

    Lets try...

    "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: Get running total in the following query

    Sean Lange (7/18/2012)


    See if this article helps. http://www.sqlservercentral.com/articles/T-SQL/68467/%5B/url%5D

    Jeff's article is certainly a must-read on this topic.

    "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: Get running total in the following query

    a2zwd (7/18/2012)


    Hi

    I have a table which holds the running total.

    DECLARE @CumCredit TABLE(RowId INT, CustomerId INT, TransId INT, Pts INT, RunningTotal INT)

    INSERT INTO @CumCredit VALUES(1,123,121,10,10), (2,123,131,20,30), (3,123,141,15,45)

    New resultset which needs 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: how to login into ssms

    harri.reddy (7/17/2012)


    hi

    i need to add my user name into ssms,how to login first in order to add another user.

    like sa or what password?

    First, a little more detail would help here....

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

    SQLSACT (7/17/2012)


    Hi All

    How would I setup a script to copy files from a shared location on one server, to a shared location on another server?

    The extension of the files 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: restricting values a variable can be assigned

    dndaughtery (7/17/2012)


    Is there a way to do it in the declaration?

    I was told someone interviewing me would ask this. In my 7 years of DB Development Ive never had 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 do I get the all columns of a row for the row with the highest value of a column

    -- Sample code

    CREATE TABLE #T(ID INT, Unit INT)

    INSERT INTO #t

    SELECT 1,33 UNION ALL

    SELECT 2,33 UNION ALL

    SELECT 3,25 UNION ALL

    SELECT 4,55 UNION ALL

    SELECT 5,55

    -- Query

    SELECT MAX(ID) ID, MAX(Unit) Unit

    FROM #t

    GROUP BY...

    "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 help me with this query

    Sean Lange (7/12/2012)


    The whole series of subselects sure makes that far more complicated than it needs to be.

    Not sure if what you posted produces what the OP wants but 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: Please help me with this query

    I think this is what you are looking for.

    -- Sample data

    DECLARE @salesStore TABLE([CustomerID] VARCHAR(20));

    DECLARE @MyTable TABLE(val varchar(20));

    INSERT INTO @salesStore VALUES ('xxx'),('yyy'),('zzz');

    -- Insert statement

    INSERT INTO @MyTable

    SELECT * FROM

    (

    VALUES ('Store'),('CustomerID'),('int'),('10'),('Sales'),('CustomerID'),('PK_Store_CustomerID')

    )...

    "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: Converting yyyy/mm/dd hh:mm:ss

    CELKO (7/11/2012)


    There is only one display format in ANSI SQL; the ISO-8601 version with dashes "yyyy-mm-dd HH:MM:SS.sssssss". Please notice I said display format.

    SQL is an abstract model of data. We...

    "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: Renamed AD users' accounts, now some SQL Servers can't get info

    schleep (7/11/2012)


    We changed some users AD accounts to a new name (samaccountname, displayname, logon, etc..)

    On one SQL server (2 instances), we get the following error on setuser.

    Could not obtain information...

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