Forum Replies Created

Viewing 15 posts - 4,696 through 4,710 (of 7,619 total)

  • RE: Index and Optimiser question.

    It depends. If the nonclustered index contains all columns needed to satisfy the query, SQL will not go back to the main table.

    If you (almost) search the table by...

    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: Help with While Loop

    DECLARE @KEYIDVALUE varchar(30) = ''

    DECLARE @BASECODE varchar(10)

    DECLARE @ASSETUID varchar(15)

    DECLARE @CATCODE varchar(10)

    DECLARE @COMPONENTNO varchar(3)

    DECLARE @QUALRATING INT

    DECLARE @MISSIONRATING INT

    DECLARE @CURRENTDATE varchar(8)

    DECLARE cursor_assets CURSOR LOCAL FAST_FORWARD FOR

    SELECT Asset_UID + CatCode,

    ...

    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: Varchar invalid for sum operator

    Try this:

    select sum(cast(cast(replace(Enter_your_field_name, ',', '') as decimal(28, 6) as int)) 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: Foreign Keys

    Fwiw, here's my version of it, with an optional TRUNCATE (currently commented out) of the tables in between the DROP and ADD. I use this script, for example, to...

    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: Trigger and email notification

    Eugene Elutin (10/28/2015)


    Lowell (10/28/2015)


    Sergiy (10/27/2015)


    I would strongly recommend not to run sending emails or any other kind of external operations from a trigger.

    And glitch in the functionality beyond SQL Server...

    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: Date Function (Possibility)

    SQLPain (10/27/2015)


    Thanks Scott, I got your point and it makes sense. but somehow its still not giving me the desired result. If I run your above statement without the GROUPBY...

    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: Date Function (Possibility)

    The MIN and MAX need to operate on the dates in the table, not on GETDATE(), therefore more like this:

    SELECT LoanID As [Loan ID]

    FROM APayments

    Where DraftDate > DATEADD(DAY, DATEDIFF(DAY, 0,...

    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: Enable and disable trigger

    I'd suggest not disabling a trigger unless it's absolutely necessary, and it almost never is.

    You can instead use CONTEXT_INFO() to pass a flag to the trigger to "tell" it whether...

    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: Just Some Help To Impress My New Boss Pls

    In the future, actual SQL statements to create the tables and insert rows would be required. But, for this request, the code should do what you're trying to do,...

    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: Scripting a query that needs all values.

    SELECT rtmi.ItemID

    FROM tbl_RF_Tags_Map_Items rtmi

    WHERE rtmi.TagID IN (1, 8, 62)

    GROUP BY rtmi.ItemID

    HAVING MAX(CASE WHEN rtmi.TagID = 1 THEN 1 ELSE 0 END) = 1 AND

    MAX(CASE WHEN rtmi.TagID...

    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: Processes That Update a Certain Column

    Also look at sys.sql_expression_dependencies (or, if SQL 2005 only, at sys.sql_dependencies). Naturally that view is only for non-dynamic SQL references.

    Or just right-click on the table name in SSMS and...

    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: Scripting a query that needs all values.

    In general, you can use an approach like below to efficiently determine if specific, multiple tags match for the same item. Naturally we'd need more details to get any...

    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 no longer Archivng Records

    So I guess the tblCall table has only one row? Otherwise @Call_Date could be set to any row value from that table. That would make it almost impossible...

    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: CASE Statement with Date

    You need to be aware that recursion will be much, much slower, and much, much more CPU and memory overhead, than a tally table.

    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: Query on a large database

    You must cluster the table properly to get good performance from large tables. You can instead try creating gazillions of covering indexes, to cover each (major) query, but...

    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,696 through 4,710 (of 7,619 total)