Forum Replies Created

Viewing 15 posts - 4,936 through 4,950 (of 6,036 total)

  • RE: Grouping total sales by payment type

    1. Your table design is wrong.

    It must be:

    InvoiceID int,

    PaymentDate datetime,

    PaymentTypeID smallint,

    PaymentAmount money

    2. Does not matter. Fix No.1.

  • RE: Grouping total sales by payment type

    So, what's a problem?

    SELECT SUM(Cash) + SUM(Cheque) + SUM(CC) + SUM(Account) + SUM(Total) + SUM(Gst) + etc

    WHERE mydate >= @StartDate and mydate < @EndDate+1

     

  • RE: quantize ?

    Mark, you're welcome.

    Hope, you don't take all suggestions above as solutions, you take it just like directions.

    Because otherwise you are in trouble.

  • RE: quantize ?

    Jeff, are you sure 26 seconds is good enough?

    Especially comparing to under 1 second from computed column?

    Not everyone is that lucky to have 26 seconds to wait.

    I have requirement...

  • RE: is the sql server being smart or stupid?

    Who needs to read that boring ANSI stuff?

  • RE: Distinct DB Name - Table row counts

    I see a join from sysindexes to sysobjects: si.id = OBJECT_ID(so.name)

    BTW, quite, mmm..., not reasonable. It must be just si.id = so.id.

    But where is your join to...

  • RE: How to link to and retrieve from multiple values

    What are you trying to save?

    Database space or form space?

    Empty value in nvarchar cell takes 3 bytes. Every charachter adds 2 bytes.

    So, value '1,2' will take 9 bytes, smallint 1...

  • RE: Distinct DB Name - Table row counts

    1) What for?

    2) If there is no database name what will tell you which database this particular table belongs to?

  • RE: quantize ?

    Help for what?

    CREATE TABLE [citrixlog] (

    [TimeGenerated] [datetime] NULL ,

    GeneratedOnHour AS (dateadd(hh, DATEPART(hh, TimeGenerated), dateadd(dd, datediff(dd, 0, TimeGenerated), 0) ) ) ,

    [SessionID] [int] NULL ,

    [ClientName] [varchar] (255)...

  • RE: Foreign key from part of a primary key

    As I understand your ID is not unique.

    So how SQL Server must know which of ID's in primary table the ID in FK table is referencing?

    In other words: can...

  • RE: quantize ?

    1) Why all those Generated... columns are varchar(255) ?

    Just in case?

    Tinyint would be absolutely enough. Except for Year, where smallint would be required

    2) drop all those useless columns.

    3) Create 1...

  • RE: quantize ?

    Add computed colmn:

    = dateadd(hh, DATEPART(hh, Entrytime), dateadd(dd, datediff(dd, 0, Entrytime), 0) ) AS HourStart

    and create index on it.

    After that you may group by that column.

  • RE: dynamic sql

    You must use

    exec sp_executesql @sqlstmt, N'@cnt int OUTPUT', @cnt = @cnt OUTPUT

    PRINT @cnt

  • RE: dynamic sql

    Was it

    select * into #temp from basis

    or

    SET @sql = 'select * into #temp from basis'

    EXEC (@SQL)

    ?

  • RE: dynamic sql

    You did not asked the question.

    Point is: #Tables are limited to the scope.

    If you created and/or populated #Table in another dynamic statement then this table was dropped as soon as...

Viewing 15 posts - 4,936 through 4,950 (of 6,036 total)