Forum Replies Created

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

  • RE: t-sql output file in need of headers and trailers

    Is this the format that you want your information?

    header line of column names

    data

    data

    data

    footer line of column summary data?

     

    Try this:

    select 1,  'FieldOneName', 'FieldNameTwo', 'FieldNameThree'

    union

    select 2, convert(varchar(), FieldOne), , convert(varchar(), FieldTwo), ,...

  • RE: Converting smalldatetime to lose the minutes

    Can you use two pieces of data instead?

     

    Use select convert(varchar, @yourDateVariable, 1) to get the date

    Use select datepart(hour,(@yourDateVariable)) to get the hour.

     

    If you can only compare to one field,...

  • RE: MY SP IS GOING NUTS!!

    Your substring() should return a 6 digit number, starting at space 5.

    Is all of your event_num data in that format?

    You might try to test if the data is correct using...

  • RE: Error 605

    What is the code that you are running that generates this error message?

  • RE: Error 605

    What is the code that you are running that generates this error message?

  • RE: Understanding the difference between IS NULL and = NULL

    Familiarize yourself with the SQL function isnull().

    When comparing a field which may have a null value, instead of = CustomerID

    use = isnull(CustomerID, '')

    which means: If the customerid is null,...

  • RE: Convert from a table with inconsistent data

    Use the isnumeric function, to select only those reference numbers that can be converted to numbers.

     

    Insert Into #Temp(RefNo)

    select refno from Table

    where isnumeric(refno) = 1

     

  • RE: Select distinct values from seperate tables

    Oops!

    I do apologize. I left out the crucial GROUP BY ResJoinID.

     

    This is what is needed:

    Join

    (select ResJoinID, max(ChangeDate) as LatestDate

    from SAVA.SAVA_SAVDJN

    GROUP BY ResJoinID

    )...

  • RE: Better way to do this?

    Do you have any triggers firing on updating your Employee table? That would really slow performance down to a crawl.

  • RE: How to do an insert to another server using TSQL?

    has the other server been set up as a linked server?

  • RE: intersting sql puzzle

    Here's a much smaller teaser.

     

    READ this code.

     

    print 'hello, David'

    /*

    go

    print 'hello, Allen'

    go

    */

    print 'Goodbye, All'

     

    Before running it, see if you can anticipate what the results will be. You'll be surprised.

  • RE: 30 mins report

    Here's how to group the data by half hour. Use datepart to isolate the hour, and again to isolate the minutes. Group the minutes by using a case statement to...

  • RE: Select distinct values from seperate tables

    Let's reorganize the logic here. We need to limit the results to the latest date for each member, so we will use a derived table as a sub-query. I've added...

  • RE: format datetime field

    DatePart returns a number, not a string. Use convert to change the datepart to a string.

     

    SELECT convert(varchar(4), DatePart(year, datefield))

    + '-'

    + convert(varchar(2), DatePart(month, datefield))

     

    Let...

  • RE: Dynamic IN Clause

    Your parameter @SQL becomes one string;

    even though print @sql returns the value 'LMTO','MMAG', that value is stored in memory as the equivalent of "'LMTO'',''MMAG'", and does not...

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