Forum Replies Created

Viewing 15 posts - 4,771 through 4,785 (of 7,613 total)

  • RE: Find characters before and after _

    SELECT LEFT(column_name, CHARINDEX('_', column_name + '_') - 1) AS before_underscore,

    SUBSTRING(column_name, CHARINDEX('_', column_name + '_') + 1, 2000) AS after_underscore

    FROM table_name

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Dynamic SQL Question

    Luis Cazares (9/21/2015)


    WayneS (9/21/2015)


    Kristen-173977 (9/20/2015)


    GilaMonster (9/19/2015)


    protecting against SQL Injection is done, in most cases, by ensuring that it is parameterised, except for the rare scenario where the user input...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Error while rebuild indexes

    This really looks like a trigger. Check for db-level (DDL) triggers. If not, check for server-based triggers (that seems unlikely in this case, though). For example:

    SELECT t.*

    FROM...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: What type of Index would be suitable

    SQL provides some help here.

    You can use missing index views

    sys.dm_db_missing_index*

    and the index stats view:

    sys.dm_db_index_usage_stats

    to help determine what indexes to create.

    First and absolutely foremost, you need to determine and implement the...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Best way to handle like% on column too large for an index

    If you don't require an nvarchar search, you can use varchar and get 900 chars to search.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Best way to handle like% on column too large for an index

    Since you're always searching at the start of the string, you could add a persisted computed column of ~900 bytes and search on that:

    ALTER TABLE ourtable

    ADD bigcolumn_search AS CAST(LEFT(bigcolumn, 450)...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to Exclude based on Condition?

    Here's another method to try, just in case:

    SELECT

    ta.last_name,

    ta.first_name,

    tb.ID

    FROM

    TableA ta

    INNER...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: get week numbers from dates, saturday being start of the week,

    That code is dependent on the DATEFIRST setting, and I don't believe it's accurate anyway. Maybe this?:

    --additional dates for testing/verification

    INSERT INTO #weekdays (datevalue, numericvalue) VALUES

    ('20150101', 1000),

    ('20150102', 1001),

    ('20150103', 1001),

    ('20150104', 1001),

    ('20150105',...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Re-design messaging table SQL Server 2008

    The design is basic, but it seems workable for very straightforward messaging.

    Just some possibilities, not necessarily better than what you have:

    1) I agree with an identity column on the Message...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Update a table with date when there are new records in another table.

    If instead of sync'ing up just once a day, or some other slow schedule, you want an up-to-the-second value, why not just get the value from the actual table itself...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Implicit conversion comparing INT column to 0

    I was just using CAST to show that it would avoid the implicit conversion, but it still didn't resolve the need to recompile. This is just a failure on...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Implicit conversion comparing INT column to 0

    Thanks for the follow up.

    Interesting, and bizarre. We can prevent the implicit conversion using CAST. But we still have to recompile even to avoid a full query scan...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Stored procedure returning different data sets based on input variable

    Kristen-173977 (9/16/2015)


    ScottPletcher (9/16/2015)


    If you're trying to return a result set, not sure if that will work the same or not.

    We do both ways and I can't say I've ever known...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Dynamic String Replacement

    If you're going to allow that, easiest would be to then quote all the values:

    Select 'Apple=''5'',Orange=''10,11,12'',Banana=''11''' UNION ALL

    Then you can use the same technique with a delimiter of ''',' instead...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Stored procedure returning different data sets based on input variable

    Maybe you could do something like this:

    CREATE PROCEDURE dbo.GetSomeData (@rptType INT, @customerID INT)

    AS

    SET NOCOUNT ON

    IF @rptType = 1

    EXEC dbo.rpt_1 @customerID

    ELSE IF @rptType = 2

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 4,771 through 4,785 (of 7,613 total)