Forum Replies Created

Viewing 15 posts - 49,111 through 49,125 (of 49,552 total)

  • RE: Dummy FAQ of the day - outputting parameters

    In theory

    CREATE PROCEDURE TestOutput (

     @InputParameter INT

     @OutputParameter INT OUTPUT

    )

    AS

    .....

    DECLARE @Result INT

    EXEC TestOutput @InputParameter = 1, @OutputParameter = @Result OUTPUT

    Note the OUTPUT keyword, both when creating the stored proc and wne...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Avoiding Cursors

    and statistics cannot be mintained on them, so the optimiser has little to no idea how many rows are in the table variable when it generates a query plan.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Joining tables with sql authentication

    If you are going to be doing this kind of query, create a linked server and map the windows authenticated logins on one to a sql authenticated login on the...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Cursors and nested Cursors

    Cursors, especially nested cursors are not going to work very well, ever. I suggest a set-based solution.

    This isn't a complete solution, but should give you a good idea where to...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Trapping errors while truncating a table

    IF EXISTS(SELECT 1 FROM mytable)

     RAISERROR (...)

    No need for variables or anything.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Simplicity

    I usually use this when I'm optimising queries.

    set

    statistics io on

    set statistics time on

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Help writing a SP to return database properties

    From books online

    status

    int

    Status bits for the growth value in either megabytes (MB) or kilobytes (KB).

    0x2 = Disk file.

    0x40 = Log file.

    0x100000 = Growth. This...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Date comparision issue Help !! Urgent

    I tend to use this one. Not sure if it's the best, but it is way better than the usual cast as varchar version. Haven't seen any strange issues

    SELECT CAST(FLOOR(CAST(GETDATE()...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: How to drop a constraint where the constraint name is variable?

    What does this return?

    DECLARE @val VARCHAR(50)

    SELECT name from dbo.sysobjects where OBJECTPROPERTY(id, N'IsConstraint') = 1 AND name like 'PK__TestTable%'

    select @val = name from dbo.sysobjects where OBJECTPROPERTY(id, N'IsConstraint') = 1 AND name...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: How to drop a constraint where the constraint name is variable?

    If you print the string instead of executing it, what does it contain?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: How to drop a constraint where the constraint name is variable?

    You'll need to use dynamic SQL in this case, as an alter table can't take a variable.

    DECLARE @val VARCHAR(50)

    select @val = name from dbo.sysobjects where OBJECTPROPERTY(id, N'IsConstraint') = 1 AND...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Date comparision issue Help !! Urgent

    Easiest, yes, fastest, no.

    Using a function on a column in the where clause of a query will prevent the optimiser from using any index that may exist on that...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Table Lock on a Simple Update .. Using PrimaryKey as the only value in the WHERE clause // The whole table locks

    What type is the TAB lock? S, X, IX, Sch-S?

    An IX lock on table level is fairly normal when doing modifications. It's not a full exclusive lock, it's there in...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: The Best Job

    I'd love to work in the 3D graphics industry. I do modelling and rendering as a hobby, but I'm no where near as good as the professionals

    That, or be an...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Data Manipulation - creating new tables

    Table A to be able to create 1 row for each distinct gr# with first occurence of toname and fromname

    What do you mean by first? First alphabetically? Is there another...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 49,111 through 49,125 (of 49,552 total)