Forum Replies Created

Viewing 15 posts - 2,821 through 2,835 (of 3,008 total)

  • RE: Table with unique Random Number column

    If you want an integer, you can use this as the default for your column:

    abs(convert(int,convert(varbinary(16),newid())))
  • RE: Calendar and Business Date Functions/Calculations

    Using DATENAME eliminates dependency on the setting of DATEFIRST, but it introduces a dependency on the setting of LANGUAGE.

    This code gives a day of week number that is independent of...

  • RE: How to find duplicate email addresses between 3 tables

    This should do it, and it shows the breakout by type.

    select
     EMAIL_ADDRESS,
     ACCOUNT_COUNT= sum(ACCOUNT_COUNT),
     LEAD_COUNT= sum(LEAD_COUNT),
     CONTACT_COUNT= sum(CONTACT_COUNT),
     TOTAL_COUNT  = sum(ACCOUNT_COUNT+LEAD_COUNT+CONTACT_COUNT)
    from
     (
     select
      EMAIL_ADDRESS = EMAILADDRESS1,
      ACCOUNT_COUNT = count(*),
      LEAD_COUNT = 0,
      CONTACT_COUNT = 0 
     from
      ACCOUNTBASE
     group by
      EMAILADDRESS1
     union all
     select
      EMAIL_ADDRESS = EMAILADDRESS,
      ACCOUNT_COUNT = 0,
      LEAD_COUNT = count(*),
      CONTACT_COUNT = 0
     from
      LEADS
     group by
      EMAILADDRESS 
     union all
     select
      EMAIL_ADDRESS =...
  • RE: IsoWeek function strange behaviour

    Your function depends on the setting of DATEFIRST, and the default setting for DATEFIRST depends on the national language setting of SQL Server.

    The function on this link is independent...

  • RE: Function help please

    You can use a date table, but I doubt if you will find one that does exactly what you want, because the output you listed has an inconsistent format for...

  • RE: Sql Modeling Tools

    You can use them, but you should remember that it is not really a data modeling tool, but a way to build and maintain a database with a GUI tool that...

  • RE: Filegroup on the SAN...

    The problem with splitting data that way is that it assumes that the workload is evenly distributed across the files.  It is rare to actually have accurate information about that,...

  • RE: Foreign Key/Primary Key GRRR!

    If you are planning on doing this in a production database where there are live transactions happening, dropping or disabling the foreign key constraints is a very bad idea.  You...

  • RE: Foreign Key/Primary Key GRRR!

    It is better to bcp the data into staging tables, and then update rows that already exist that have changed, and insert the new rows.

     

  • RE: Restore a database using a Job in SQL Server 2005

    I like to do it this way, because it prevents anyone from connecting to the database.  Even a single user connection will cause the restore to fail.

    use master
    alter database My_Database_Name...
  • RE: Date ranges: per calendar week

    Here is an alternate solution, using your test data.  This one groups by the start of week date, using Monday as the start of the week.

    This solution has a couple...

  • RE: Can anyone think of a good reason for NOT having a PK?

    I would just point out that a table without a primary key is not even in first normal form.

    Personally, I would never accept a table into production without a primary key.

    Someone mentioned...

  • RE: Drinking the Kool-Aid

    This sounds similar to an IT fad of the past, Decision Support Systems.

    I remember being at a meeting with the company president where we were asked to introduce ourselves and...

  • RE: How to create TIme Dimension package

    The function on the link below is designed to load a date dimension table for any range of dates that you supply.  It contains over 60 columns of date attributes.

    It...

  • RE: Database Tuning Advisor recommending too many Indexes on a Table??

    The method I use is to capture at least three different workloads, and look at the index recommendations from each one.  Then I create only the indexes that were recommended...

Viewing 15 posts - 2,821 through 2,835 (of 3,008 total)