Forum Replies Created

Viewing 15 posts - 5,206 through 5,220 (of 7,619 total)

  • RE: Copy/move problems with detached databases

    Detach now (since SQL 2005, IIRC) changes the security on the files -- this is an intentional thing by MS, as a "security feature". But it's been a royal...

    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: unable to deallocate cursor properly (A cursor with the name 'tnames_cursor' does not exist.). Help needed.

    You check for a "GLOBAL" cursor but you don't explicitly specify a GLOBAL cursor when you DECLARE it. Whether a cursor is local or global can vary based 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: SELECT COUNT(*) vs DMVs to get row count

    You should look into RCSI as well. That may solve your issue even more completely and with less effort during coding :-).

    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: Funtion Not Working

    CREATE FUNCTION [dbo].[CheckLoginDetails_Username] (

    @SuppliedUsername nvarchar(150),

    @SuppliedPassword nvarchar(150)

    )

    RETURNS bit

    AS

    BEGIN

    RETURN (

    SELECT CASE

    ...

    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: Where clause question

    Maybe a join to reduce repetition of comparisons:

    SELECT bf.BF_ORGN_CD, bf.BF_BDOB_CD, bf.BF_TM_PERD_CD, bf.data

    FROM BF_DATA bf

    INNER JOIN (

    VALUES('A1', 'B1', 'C1'),

    ...

    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: Separate drives for mdf / ldf on same storage

    There used to be both recoverability and performance reasons for the split. Now it's more about recoverability than performance.

    If possible, you want the data and logs on separately "fail-able"...

    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: Stuck with LIKE criteria

    Eirikur Eiriksson (4/13/2015)


    ScottPletcher (4/13/2015)


    Eirikur Eiriksson (4/13/2015)


    ScottPletcher (4/13/2015)


    Here's an alternative approach, also using CROSS APPLY, that can take advantage of the (presumed) clustered index on prefix.PREFIX_VALUE; no guarantee, but it might...

    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: Stuck with LIKE criteria

    jgale 70688 (4/13/2015)


    Thank you for the replies.

    Both solutions did work. However, the data I'm working with is slightly more complex than my simple example. My main data table is a...

    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 would be the proper way to add this to my where clause

    Grant Fritchey (4/13/2015)


    It made me curious, so I put this together real quick:

    SELECT a.City,

    a.PostalCode

    FROM Person.Address AS a

    WHERE ...

    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: Stuck with LIKE criteria

    Eirikur Eiriksson (4/13/2015)


    ScottPletcher (4/13/2015)


    Here's an alternative approach, also using CROSS APPLY, that can take advantage of the (presumed) clustered index on prefix.PREFIX_VALUE; no guarantee, but it might perform better.

    SELECT...

    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 would be the proper way to add this to my where clause

    Luis Cazares (4/13/2015)


    ScottPletcher (4/13/2015)


    Go ahead and add DISTINCT to each separate query on which it's applicable:

    SELECT DISTINCT omlSalesOrderID

    FROM m1_dc.dbo.SalesOrderLines

    WHERE omlPartID='finalmile'

    UNION

    SELECT ompSalesOrderID

    FROM m1_dc.dbo.SalesOrders

    WHERE ompShippingMethodID='JBFM'

    Why? :unsure:

    It's...

    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: Stuck with LIKE criteria

    Here's an alternative approach, also using CROSS APPLY, that can take advantage of the (presumed) clustered index on prefix.PREFIX_VALUE; no guarantee, but it might perform better.

    SELECT p_cross_apply.PREFIX_VALUE, SUM(d.DATA_VALUE) AS...

    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 would be the proper way to add this to my where clause

    Go ahead and add DISTINCT to each separate query on which it's applicable:

    SELECT DISTINCT omlSalesOrderID

    FROM m1_dc.dbo.SalesOrderLines

    WHERE omlPartID='finalmile'

    UNION

    SELECT ompSalesOrderID

    FROM m1_dc.dbo.SalesOrders

    WHERE ompShippingMethodID='JBFM'

    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: aggregate function or the GROUP BY clause Error

    In general, since you want to avoid grouping by varchar columns anywhere, as it's not very efficient, delay converting numeric codes until the outer-most query you can.

    select DB_NAME(a.database_id) AS [Database...

    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 reduce execution time of median calculations

    Off the top of my head, I would use a temp table here, something like below. I don't have time to finish all the median values in the SELECT,...

    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 - 5,206 through 5,220 (of 7,619 total)