Forum Replies Created

Viewing 15 posts - 2,581 through 2,595 (of 3,543 total)

  • RE: Month end date

    Nice one roockmoose

    Knew there was a way without convert but could not remember it

     

  • RE: Month end date

    create function getMthEndDate (@date datetime)

    returns datetime

    as

    begin

    return DATEADD(d,-1,DATEADD(m,1,LEFT(CONVERT(varchar,@date,112),6)+'01'))

    end

    go

  • RE: How to find a number in a space separated string?

    declare @wantednum varchar(10)

    set @wantednum = '10'

    select ID

    from

    where charindex(' ' + @wantednum + ' ',' ' + nums + ' ') > 0

    Note that this...

  • RE: update table...

    on b.field1 = a.field - 1

    should have been

    on b.field1 = a.field1 - 1

    If field1 is not int then you will have to cast the column to the correct data...

  • RE: Cast problem

    again this points to a data issue

    run this

    select [service date]

    from

    where [service date] > 0

    and isdate([service date]) = 0

    to what values sql considers not a date

     

  • RE: Cast problem

    You cannot convert character zero to a datetime.

    You can convert integer zero to datetime as in

    select cast(0 as datetime)

    which will give you 1900-01-01 00:00:00.000

    You will have to change zeros to...

  • RE: Cast problem

    Check that all your input data is formatted as yyyymmdd.

    select cast(cast(20031224 as varchar) as datetime)

    will work

    select cast(cast(20032412 as varchar) as datetime)

    will give conversion error

     

  • RE: How do i group by month?

    SELECT [Part#],

      SUM(CASE WHEN MONTH([Replacement Date]) = 1  THEN [Replace Qty] ELSE 0 END) AS [Jan],

      SUM(CASE WHEN MONTH([Replacement Date]) = 2  THEN [Replace Qty] ELSE 0 END)...

  • RE: update table...

    update a

    set a.field2 = b.field2

    from tablea a

    inner join tablea b

    on b.field1 = a.field - 1

    where a.field2 is null

  • RE: Dynamic SQl

    as per above, try this

    declare @sql nvarchar(100), @idno int

    set @sql = 'insert into ' + @databasename + '.dbo.tablea (cola,colb values (valuea,valueb) set @idno = SCOPE_IDENTITY()'

    exec sp_executesql @sql,N'@idno int output',@idno...

  • RE: extract data

    DTS is Data Transformation Services and allows the copying and transformation of data between databases and or files.

    BCP is Bulk Copy Program and allows the transfer (in or out) of data...

  • RE: Output value from sproc

    Try this

    alter procedure prRecCount @vTbl varchar(25) as

    declare

     @sql varchar(2000),

     @vCnt int

     set @sql = 'select @vCnt = cnt from openquery( {servername},''select count(*) cnt from ' + @vTbl +''')'

     exec sp_executesql @sql,

  • RE: isql command problem

    Not knowing what the output looks like but...

    isql has a default output width of 80. If the output line is longer isql will split it into several lines.

    So,

    isql -Q "select...

  • RE: SQL Server randomly drops client connections

    I used to get this with SQL7.

    I installed SQL7 SP4 and MDAC 2.7 (on both client and server) and problem went away.

  • RE: extract data

    Why not use DTS or BCP. You can schedule either in sql server agent.

Viewing 15 posts - 2,581 through 2,595 (of 3,543 total)