stored procedure is only returning one letter

  • I have a stored procedure like this :
    USE [MyDatabase]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[sp_logvrnitev]
        @p1 int,
        @p2 varchar
    AS
    BEGIN
    update KOLESARSKI_ZURNAL set DATUM_VRNITVE=CURRENT_TIMESTAMP,KOLO_SPREJEL=@p2 where KOLO=@p1
    END

    On execution the @p2 parameter returns only the first letter of a string.
    Example : Instead of 'Senchi' it returns just 'S'

  • Senchi - Saturday, January 14, 2017 9:01 AM

    I have a stored procedure like this :
    USE [MyDatabase]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[sp_logvrnitev]
        @p1 int,
        @p2 varchar
    AS
    BEGIN
    update KOLESARSKI_ZURNAL set DATUM_VRNITVE=CURRENT_TIMESTAMP,KOLO_SPREJEL=@p2 where KOLO=@p1
    END

    On execution the @p2 parameter returns only the first letter of a string.
    Example : Instead of 'Senchi' it returns just 'S'

    your procedure declaration says  @p2 varchar, and not  @p2 varchar(128) for example.
    the default size is(1) unless you say otherwise.
    in a cast or convert command, the default size is(30), and that may be where you are making an assumption that woull be incorrect.


    ALTER PROCEDURE [dbo].[sp_logvrnitev]
        @p1 int,
        @p2 varchar(256)
    AS
    BEGIN
    update KOLESARSKI_ZURNAL set DATUM_VRNITVE=CURRENT_TIMESTAMP,KOLO_SPREJEL=@p2 where KOLO=@p1
    END

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell - Saturday, January 14, 2017 9:42 AM

    Senchi - Saturday, January 14, 2017 9:01 AM

    I have a stored procedure like this :
    USE [MyDatabase]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[sp_logvrnitev]
        @p1 int,
        @p2 varchar
    AS
    BEGIN
    update KOLESARSKI_ZURNAL set DATUM_VRNITVE=CURRENT_TIMESTAMP,KOLO_SPREJEL=@p2 where KOLO=@p1
    END

    On execution the @p2 parameter returns only the first letter of a string.
    Example : Instead of 'Senchi' it returns just 'S'

    your procedure declaration says  @p2 varchar, and not  @p2 varchar(128) for example.
    the default size is(1) unless you say otherwise.
    in a cast or convert command, the default size is(30), and that may be where you are making an assumption that woull be incorrect.


    ALTER PROCEDURE [dbo].[sp_logvrnitev]
        @p1 int,
        @p2 varchar(256)
    AS
    BEGIN
    update KOLESARSKI_ZURNAL set DATUM_VRNITVE=CURRENT_TIMESTAMP,KOLO_SPREJEL=@p2 where KOLO=@p1
    END

    Thank you.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply