Forum Replies Created

Viewing 15 posts - 2,536 through 2,550 (of 7,619 total)

  • Reply To: Dynamically Choose Columns Names

    Maybe use a separate view for each language you need.  The view itself would be static but would be generated dynamically.

    If you want to try this approach, and want further...

    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".

  • Reply To: Max function and indexes

    Jeffrey Williams wrote:

    Chris Harshman wrote:

    looking at your execution plan, 9 million rows at 15 bytes per row is not very large, so it was able to read the entire table and 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".

  • Reply To: Calculating totals based on a column flag

    SELECT 
    OT.Stuff1,
    OT.Stuff2,
    [...],
    TotalStuff = TotalStuff -
    ...

    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".

  • Reply To: is WITH (ROWLOCK) hint a culprit in this code?

    Shouldn't matter, unless it's part of a (much) larger transaction.  A rowlock (at least) will be required to do the UPDATE anyway.  But you could remove it, just in case.

    Much...

    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".

  • Reply To: Calculating totals based on a column flag

    I'll assume that:

    1) you have some way to get the OrderType from the OrderID since you'll need the Type to join to the Buck bits table as it's given

    2) you...

    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".

  • Reply To: Query stops retuning records after 6:00pm - Datetime datatype

    Thanks for the DDL.  Yeah, the standard format of:

    WHERE TransactionDate >= CAST(GETDATE() AS DATE))

    will work just find for finding dates >= today at midnight.

    Funny I actually tride to do 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".

  • Reply To: Create temp table in Openquery?

    I don't see how OPENQUERY would provide any performance benefit here.  But, no, you can't create a temp table using OQ.

    If you can provide more details of your specific situation,...

    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".

  • Reply To: tyring to convert a varchar to a Date

    Don't limit yourself to a single format.  Just CAST it to date: if it's a valid date in any format, you'll get a date back.  If not, you'll have 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".

  • Reply To: Query stops retuning records after 6:00pm - Datetime datatype

    oogibah wrote:

    I'm a noob, but what if you casted them as date so it doesnt include the  time portion?

    where CAST([TransactionDate]  AS DATE)=CAST(GETDATE() AS DATE)

    That seems like a slick solution.  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".

  • Reply To: Query stops retuning records after 6:00pm - Datetime datatype

    What is the data type of the TransactionDate column?  If it's in the date/datetime category, then this condition:

    where [TransactionDate] >= DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)

    should pull all rows on or...

    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".

  • Reply To: Error - Column 'INV1.LineNum' is invalid in the select list

    SQL can't execute the query as you've written it because there may be multiple values of T1.LineNUM for a given combination of DocEntry and ChapterID.

    For example, suppose these two rows...

    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".

  • Reply To: @@ROWCOUNT in a Exec() with identity_insert

    You need to use sp_executesql rather than just exec(), because sp_exec allows value(s) to be returned:

    DECLARE @SQLSTR nvarchar(500)
    DECLARE @DELCOUNT int
    ...
    SET @SQLSTR = 'Set IDENTITY_INSERT Table_2 ON;DELETE 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".

  • Reply To: Datediff between dates, but exclude extra leap year day

    I think the code below is much simpler.  The code is complete, no function needed.  And, yes, I took a short-cut, so, yes, this code will fail for 2100.  If...

    • This reply was modified 6 years, 7 months ago by ScottPletcher. Reason: Tweaked the code

    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".

  • Reply To: Fifi Calculation

    x wrote:

    Just want to clarify here Scott, who's the idiot you are having difficulties with?

    That q obviously makes it self-evident.

    Accounting entries are not properly classified simply by a + or...

    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".

  • Reply To: Fifi Calculation

    Matt Miller (4) wrote:

    So can you do this or can't you? The ONLY question you have to ask, is if the OP's design allows negative numbers. If the OP NEEDS...

    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 - 2,536 through 2,550 (of 7,619 total)