Forum Replies Created

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

  • RE: query to find size of all tables in a database

    Here is a ready built script that will do what you want.

    Script to analyze table space usage

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61762

     

     

  • RE: Compress backup files

    You can make your backup to a compressed directory.

     

     

  • RE: Weirdest interview question?

    If you are asked this question: “If you were any animal, which one would you be and why?”, the correct answer when interviewing for a management position is:

    I...

  • 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...

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