Forum Replies Created

Viewing 15 posts - 61 through 75 (of 342 total)

  • RE: Adjust dates based on timezone

    If you are running on SQL2K:

    --Convert Local to UTC

    select DATEADD( MINUTE, DATEDIFF( MINUTE, GETDATE(), GetUTcDate()), <Local Time>)

    --Convert UTC to Local

    select DATEADD(MINUTE, DATEDIFF(MINUTE, GetUTCDate(), GETDATE()), <UTC Time>)

    Store the value in the...

  • RE: Help with SQL transactions

    Check out the Books Online under BEGIN TRAN or COMMIT TRAN. There is a lot of information there.

    Guarddata-

  • RE: Average Date time

    Assuming the data is well-mannered --

    Could you just:

    SELECT Category, AVG( CONVERT( DATETIME, <ElapseTime> ) ) AS 'Ave Elapsed'

    FROM <Table>

    GROUP BY Category

    Guarddata-

  • RE: Annual Tables

    You can use the procedure sp_rename <oldtablename>, <newtablename>

    You might want to consider the original design to assure that you really want to rename - or do you want to create...

  • RE: Export to a text file

    Would bcp work for you? You can use a query string with bcp to get just the information you desire.

    Guarddata-

  • RE: try and catch equivalent in tsql

    While there are some errors you can check for by accessing the @@ERROR variable, there are some that cannot be trapped. For these types of errors, you will want...

  • RE: Changing a column from INT to BIGINT - Urgent

    Interesting statement... "would be fantastic if we could BCP only for one row" Care to explain further? BTW - you can bcp using a query

  • RE: null column

    Not so elegant but more generic.

    SELECT * FROM Table1

    WHERE Col1 > 100

    UNION

    SELECT * FROM Table1

    WHERE Col1 IS NULL AND Col2 > 100

    Hint: You could use an OR...

  • RE: Calculate max number of bytes for a row

    One more then I will leave this... If the DTS error stops the process, you would probably be able to get away with a bps process. Since the...

  • RE: Calculate max number of bytes for a row

    What was the size of the column you were attempting to add?

    Guarddata-

  • RE: Calculate max number of bytes for a row

    Thanks Jonathan - I sometimes forget about the Information_Schema information ...but don't forget to GROUP BY Table_Name

    Guarddata-

  • RE: IN Function

    Two easy ways:

    (1) Dynamic SQL - SET @sqlCmd = 'select *

    from carrier

    where CARRIER in ( ' + @a + ')'

    sp_executesql @sqlCmd

    (2) Temporary table

    CREATE TABLE #tmpLookup (

    ...

  • RE: Calculate max number of bytes for a row

    SELECT SUM( SC.length )

    FROM sysobjects SO (NOLOCK)

    INNER JOIN syscolumns SC (NOLOCK) ON SC.id = SO.id

    WHERE SO.Type = 'U' and SO.name = <Your Table Name>

    Guarddata-

  • RE: Sub-Select in FROM clause

    This one caught me for a while also... The key is to follow the subselect with AS <name>

    SELECT myCol from ( select myCol from aTable) AS table

    Guarddata-

  • RE: insert help

    One option might be to declare the table up front with your identity column. Then use INSERT INTO <table> ( < all but ident column> )

    SELECT from source

    Granted,...

Viewing 15 posts - 61 through 75 (of 342 total)