Forum Replies Created

Viewing 15 posts - 556 through 570 (of 7,619 total)

  • Reply To: Dimensional table and Stored Procedure

    I've added comments to your code below.  Some of the code is invalid and/or doesn't make sense.

    yrstruly wrote:

    create procedure AppendAccountCommissionHistory
    as
    begin
    begin
    insert into...

    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: "ID" primary key from two separate tables as a foreign key in a new table

    You could create a combined table.  I assume (perhaps wrongly, if so, correct me) that you will have fewer than 10 professors in the table and therefore you intend that...

    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: How to get number of unique months from table

    SELECT ZipCode, COUNT(DISTINCT DATEADD(MONTH, DATEDIFF(MONTH, 0, UCLogTimeStamp), 0)) AS 'No. months'

    FROM #mytable

    GROUP BY ZipCode

    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: Case statement with time

    Phil Parkin wrote:

    pedroccamara wrote:

    I'm so sorry guys, wrong CASE

    (CASE WHEN CAST(DH.OPENING_HOUR_H AS INT) BETWEEN 10 AND 16 THEN 'Lunch' WHEN CAST(DH.OPENING_HOUR_H AS INT) BETWEEN 16 AND 19 THEN 'Snack' ELSE 'Dinner'...

    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: Case statement with time

    Sorry, but a picture of data is useless to us.  Please post usable data, that is, a CREATE TABLE and INSERT statement(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".

  • Reply To: Context_Info across databases

    It should work I think.  But 0x55555 is an odd number of chars, so the value would actually get set to 0x055555.

    Try setting it to 0x555555, that should work more...

    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: Subtract time passed midnight

    I just did a few sample rows, I'm not going to type in all that data.

    DROP TABLE IF EXISTS #data;
    CREATE TABLE #data ( ENTRY_HOUR tinyint NULL, ENTRY_MINUTE...

    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: How to Reseed an Identity Column on Temp Table After data has been removed

    You cannot update the value of an identity column.  You would to insert a new row and delete the old row.  That will be way too much overhead.

    And, as Thom...

    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: Conventions when writing queries/stored procedures

    Jeff Moden wrote:

    edwardwill wrote:

    ...but I don't think I'll ever be converted to leading commas - I think that's at least partly because I'm an English language pedant and believe that 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: Read data based on date-range in huge table is slow

    I wouldn't just arbitrarily add a non-clus index without checking existing index usage ("index usage stats") AND reviewing missing indexes ("missing index" stats).

    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: Conventions when writing queries/stored procedures

    edwardwill wrote:

    Anyway, my question is to do with square brackets and including schema names. ... My inclination is to leave off as much stuff as possible (he also used 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: Read data based on date-range in huge table is slow

    How do you typically query the table?  If you normally query by a range of datetime, then changing the clus index makes perfect sense.

    First, change the SET @table_name_pattern = '%'...

    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: Help with Joins

    Something like this.  The key is using aliases (AS ...) for the tables to make the code easier to write and to follow:

    SELECT t0.column1, t1.Description, t2.Description, ...
    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: Troubles with in memory OLTP performance degradation

    Although SQL itself should issue CHECKPOINT commands when being shut down, I've found that explicitly issuing them myself prior to shutdown often allows SQL to restart faster.  So, personally, yes,...

    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: Join aggregated queries via a date formatted YYYY-MM

    First try getting rid of extraneous parts of the query (reducing the GROUP BY in the outer query):

    SELECT [W_SE-MFG].dbo.YearMonthNo(J1.EntryDate) AS Per, SUM(J1.RunTime) AS TReg, MAX(J2.TNQ) AS TNQ
    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".

Viewing 15 posts - 556 through 570 (of 7,619 total)