Forum Replies Created

Viewing 15 posts - 346 through 360 (of 369 total)

  • RE: how ro create a table with multiple coloumns defined to a single primary key

    First, download the documentation. It is called "books online". Search with google books online for your version of sql server. This is example for SQL 2008R2 (put that in google):

    sql...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: how ro create a table with multiple coloumns defined to a single primary key

    Try a free tool XDetails (http://www.sqlxdetails.com). It really simple presents multicolumn PK, FK, column comments and other features.

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Query - Array

    If you really have to...

    split to one city, than rejoin them with less cities per row.

    But I would not join them at all. I would leave one city per row.

    Google...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Random updates from another table

    Modulo was because smaller table has less rows than big table.

    Lets say N = number of rows in the smaller table.

    Smaller table is widened in subquery with random unique...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Random updates from another table

    From the smaller table make a subquery widening it with a random ordinal number as shown in example before (row_number() over(order by newid()) construct).

    If you have unique integer (maybe PK?)...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Random updates from another table

    Why update? You could select exactly what you need and optionally store that via insert.

    Update is a low performer.

    Since you didn't specify what is random here, let's assume you have...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Table design

    Like Andrew said, it's a classic many-to-many relation. In logical data model you have two entities: A and B. One A can have (contains, is associated with, etc) multiple B's,...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Sql help: Triggers

    You could use SQL_VARIANT data type that can store any other base data type without conversion or lost precision:

    DECLARE @x AS SQL_VARIANT, @y AS SQL_VARIANT, @t AS SQL_VARIANT

    SELECT @x =...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Query - Array

    In this example full text index is very wrong solution.

    You should store each value in separate table row and use a normal index.

    Split function is here:

    -- Create sysTally table

    SELECT TOP...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Stored Procedure help

    create procedure ErrorListGet

    -- Returns comma-separated list of errors for given request

    (@reqid int,

    @Messages varchar(max) out

    ) as

    begin

    -- Bild comma-separated list of messages

    -- If you want some particular order, simply add "order...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Using Case for an Update

    CASE in not complex at all.

    I already wrote you description of what might be wrong.

    You cannot use LEFT JOIN and then update right table - if there is no matched...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Using Case for an Update

    tacy.highland (1/17/2011)


    Here's the scenario:

    UPDATE BookingActivity

    SET faretypeid =

    CASE WHEN c.FareTypeId IN (9,10,11) THEN 4

    ELSE faretypeid = b.FareTypeId

    END

    FROM Booking b

    LEFT JOIN Clients c ON b.ClientID =...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Try...Catch with transactions

    Lamprey13 stole me the word of mouth (or code from the keyboard) 😉

    That code is the best IMHO. Think of this situation: If the code inside the try-block calls a...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: CASE vs JOIN

    In short: no. You probably will not have significant performance gains if you use "mutant" CASE statement.

    It's all about the megabytes that db engine needs to read to get you...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Partition of a large Table

    This requires classic tuning procedure.

    Collect few typical queries, and start with the one that is used the most.

    Measure logical reads, eg. like this:

    SET STATISTICS IO ON

    SELECT * FROM sys.all_objects --...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths

Viewing 15 posts - 346 through 360 (of 369 total)