Forum Replies Created

Viewing 15 posts - 241 through 255 (of 267 total)

  • RE: Clear Errors

    My VB isn't great but if you use OnError to trap the error, you can then include some specific error handling in VB to check for errors (Err.Number). You'll...

  • RE: Clear Errors

    You can use @@error to determine if there is an error:

    if @@error <> 0 begin

    /* execute other statements and procedures in here */

    end

    Jeremy

  • RE: Fetched Result order if no ORDER BY clause

    I had a similar problem with temporary tables.

    I had an sp which would loop round for each each month for 3 years worth of data and inserted output...

  • RE: deleting large amout of data

    The easiet way to delete the whole of a table is:

    truncate table @tablename

    Jeremy

  • RE: Re-starting SQL Server

    You can use:

    net stop mssqlserver

    net start sqlserver

    in a .bat file executed using the at command to execute at a specific time....

  • RE: Left Outer Join problem

    Obvious when you know how.

    Thanks.

  • RE: Patindex (sql 2000)

    Use the char function:

    patindex(@value,char(9)) - tab

    patindex(@value,char(13)) - newline

    I think new line is 13 but it might be...

  • RE: Dividing in a SELECT statement

    If both fields are int then the result would be a int.

    SELECT Stage2file.newdist AS newdist,

    CAST(convert(decimal(10,2),distdlrcnt))/distcnt AS Prop_DD

    INTO dbo.rdddf2

    FROM dbo.Stage2file

    join

    dbo.Stage3file

    ON Stage2file.newdist = Stage3file.newdist

    Jeremy

  • RE: SQL Function - Deconcatenate

    This should work but no guarantees on performance:

    CREATE FUNCTION fn_charlist (@str varchar(200), @delimeter char(1) =',', @sequence int)

    RETURNS varchar(200)

    AS

    BEGIN

    declare @position smallint, @tempvar varchar(4000), @counter int, @continue...

  • RE: SQL Function - Deconcatenate

    No, you could not use this, as it stands, in a select statement.

    It might be possible to create a user defined function to do this but I'm not...

  • RE: SQL Function - Deconcatenate

    Michael,

    Try this:

    CREATE PROCEDURE [dbo].[charlist]

    @field_value varchar(4000), @delimeter char(1) =',', @sequence int, @output_val varchar(255) OUTPUT

    AS

    declare

    @position smallint, @tempvar varchar(4000), @counter int, @continue...

  • RE: Conditional Sum

    I cannot think of any other way of summing the rows until you reach a set number other than processing each row at a time. Maybe someone else does...

  • RE: Transactions

    David,

    Thanks for the idea.

    I was doing some more checking after I made the post and I'm not sure what is going on now.

    I simulated what I thought was going on...

  • RE: SQL Server (dis)Functions

    I use dynamic SQL to create code based on parameters. For example:

    create procedure testsql @colname varchar(25), @tablename varchar(25) as

    declare @sqlstring nvarchar(200)

    set @sqlstring = N'select ' + @colname +N'

    from '...

  • RE: Handling with null values

    Two ideas.

    1. Change the destination table to accept nulls.

    2. Use isnull to replace the nulls with another value:

    select isnull(column_name,replacement_value)

    from tablename

    Jeremy

Viewing 15 posts - 241 through 255 (of 267 total)