Forum Replies Created

Viewing 15 posts - 151 through 165 (of 907 total)

  • RE: LEN and DATALENGTH

    Not sure what you are referring to, but it depends on what you want. DATELENGTH returns the number of bytes, where as LEN returns the number of characters.

    Gregory Larsen,...

  • RE: Reclaiming space from Table with Zero Rows

    Problems solved. I ran a maintenance plan. Tomorrow, I'll figure out exactly which DBCC solved my problem, and let everyone know.

    Gregory Larsen, DBA

    If you looking for SQL Server...

  • RE: Reclaiming space from Table with Zero Rows

    Basically I want to release the pages that don't contain any records back to the database. Reason is because at one time these tables had a lot of records,...

  • RE: middle of string

    Might try something like:

    Update MyTable

    set colA = substring(colB,3,size(colB))

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

  • RE: julian day conversion in SQL

    Thats what I thought, so try this:

    SELECT REPLACE(CONVERT(char(10), DATEADD(day, CAST(JULIAN_DAY AS int) - 1, CAST(cast([YEAR] as char) + '-01-01' AS datetime)), 101), '/', '') AS MMDDYYYY

    FROM ISCFINAL2_POINT

    WHERE ([YEAR] = '1964')

    Gregory...

  • RE: Dynamic SQL -- Maximum nvarchar(4000) Exceeded

    When I mean is you can pass parmaters like this:

    declare @x nvarchar(4000)

    set @x = 'SELECT * FROM sysobjects where name = @name'

    exec sp_executesql @x ,N'@x nvarchar(4000), @name nvarchar(100)',@x=@x,@name=N'sysobjects'

    exec sp_executesql...

  • RE: julian day conversion in SQL

    Not sure about that error.

    What are the data types and lengths for JULIAN_DAY and YEAR?

    Are you sure all your data in these columns contains integers?

    Gregory Larsen, DBA

    If you looking for...

  • RE: julian day conversion in SQL

    What does your code look like As far as learning I would suggest you find a good book with lots of T-SQL examples. Possibly:

    http://www.sqlserverbyexample.com/

    Gregory Larsen, DBA

    If you looking...

  • RE: Dynamic SQL -- Maximum nvarchar(4000) Exceeded

    Yes you can also do what J. Moseley

    is suggesting. One advantage I can see in using sp_executesql is you can pass and return parameters from the dynamic SQL. ...

  • RE: Opposite of dayofyear

    Try something like this:

    declare @jdate char(7)

    set @jdate = '2003260'

    select convert(char(10),

    dateadd(day,cast(substring(@jdate,5,7) as int)-1,cast(substring(@jdate,1,4) + '-01-01' as datetime))

    , 101)

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at...

  • RE: julian day conversion in SQL

    Sure! I think the where clause is what you are looking for:

    select replace(convert(char(10),

    dateadd(day,cast(jday as int)-1,cast(jyear + '-01-01' as datetime))

    , 101),'/','') as MMDDYYYY

    from mytable

    where jyear = '2003'

    Now if...

  • RE: Dynamic SQL -- Maximum nvarchar(4000) Exceeded

    Here try some thing like this.

    declare @x nvarchar(4000)

    declare @y nvarchar(4000)

    declare @z nvarchar(4000)

    set @x = 'SELECT ''Place first 4000 characters here, '

    set @y = 'second 4000 here,'

    set @z...

  • RE: julian day conversion in SQL

    Maybe these examples will help. There is a 1, 11, 245,365, 366 for Julian Day.

    declare @jday varchar(3)

    declare @jyear varchar(4)

    set @jday = '245'

    set @jyear = '2000'

    select replace(convert(char(10),

    dateadd(day,cast(@jday as int)-1,cast(@jyear +...

  • RE: Retrieve Last Record

    Or to retrieve the last record by myid issue:

    select * from mytable where myid = (select max(myid) from mytable)

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my...

  • RE: julian day conversion in SQL

    Something like this might work for you:

    declare @jdate char(7)

    set @jdate = '2003226'

    select convert(char(10),

    dateadd(day,cast(substring(@jdate,5,7) as int)-1,cast(substring(@jdate,1,4) + '-01-01' as datetime))

    , 101)

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out...

Viewing 15 posts - 151 through 165 (of 907 total)