Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1046329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:07:48+00:00 2026-05-16T16:07:48+00:00

I have a stored procedure that works correctly when I execute the stored procedure

  • 0

I have a stored procedure that works correctly when I execute the stored procedure from SQL Server Management Studio. Unfortunately, it doesn’t behave the the same way on the production server. On an insert statement, it is only inserting some of the values and the rest are NULL. The NULL values are coming from user defined scalar function calls (which also work correctly when executed from Management Studio). Has anyone run into anything similar? I was thinking it might be a permissions issue, but I connected to the database through Management Studio with the production connection credentials and saw the same behavior. I’m a C# developer that normally works with ORMs, so I’m definitely no SQL expert. Thanks in advance, guys.

Here is the code:

BEGIN 
    DECLARE @UserExists int 
    SET @UserExists = 0
    SELECT @UserExists = COUNT(*) FROM UserPass WHERE UserId = @UserID AND PortalID = @PORTALID


    --If the Action is add and a User Exists change the Action to EDT (Update)
    IF @Action = 'ADD' AND @UserExists > 0 
     SET @Action = 'EDT'

    --Get All Of the Properties for this User
    DECLARE @EMAIL nvarchar(255)
    DECLARE @FIRSTNAME nvarchar(50) 
    DECLARE @LASTNAME nvarchar(50) 
    DECLARE @GENDER char(1) 
    DECLARE @BIRTHDATE smalldatetime 
    DECLARE @ADDRESS nvarchar(50)
    DECLARE @CITY nvarchar(50) 
    DECLARE @STATE nchar(2) 
    DECLARE @COUNTRY nvarchar(50) 
    DECLARE @POSTALCODE nvarchar(10) 
    DECLARE @TELEPHONE nvarchar(20) 
    DECLARE @CELL nvarchar(20) 
    DECLARE @EMAILPERMISSION bit 
    DECLARE @TEXTPERMISSION bit 
    DECLARE @UPDATEDIRECTION nvarchar(3)

    BEGIN TRY
      SELECT @BIRTHDATE = CAST(dbo.GetPropertyValue(@PORTALID,@USERID,'Birthdate') AS SmallDatetime)

    END TRY
    BEGIN CATCH
      SELECT  @BIRTHDATE = NULL
    END CATCH

    SELECT @EMAIL = Email,
        @FIRSTNAME = dbo.Proper(Firstname), 
        @LASTNAME = dbo.Proper(Lastname),
        @GENDER = dbo.GetPropertyValue(@PORTALID,@USERID,'Gender'),
        @ADDRESS = dbo.GetPropertyValue(@PORTALID,@USERID,'Street'), 
        @CITY = dbo.Proper(dbo.GetPropertyValue(@PORTALID,@USERID,'City')), 
        @STATE = Upper(dbo.GetState(dbo.GetPropertyValue(@PORTALID,@USERID,'Region'))), 
        @COUNTRY = dbo.GetPropertyValue(@PORTALID,@USERID,'Country'), 
        @POSTALCODE = dbo.GetPropertyValue(@PORTALID,@USERID,'Postalcode'), 
        @TELEPHONE = dbo.STRFILTER(dbo.GetPropertyValue(@PORTALID,@USERID,'Telephone'),'0,1,2,3,4,5,6,7,8,9'), 
        @CELL = dbo.STRFILTER(dbo.GetPropertyValue(@PORTALID,@USERID,'Cell'),'0,1,2,3,4,5,6,7,8,9'), 
        @EMAILPERMISSION = dbo.GetPropertyValue(@PORTALID,@USERID,'eNewsLetter'), 
        @TEXTPERMISSION = dbo.GetPropertyValue(@PORTALID,@USERID,'TextPermission') 
    FROM Users 
    WHERE UserId = @USERID 


        -- Insert new user
        IF @Action = 'ADD'
            BEGIN

                INSERT INTO UserPass
                  (UserID, Portalid, CreatedDate, Username, UserPass.Password, email, firstname, lastname, gender, birthdate, UserPass.address, city, UserPass.state, country, postalcode, telephone, cell, emailpermission, textpermission, UpdateDirection)
                VALUES 
                  (@UserID, @PORTALID, @CREATEDDATE, @Username, @Password, @EMAIL, @FIRSTNAME, @LASTNAME,@GENDER, @BIRTHDATE, @ADDRESS, @CITY, @STATE, @COUNTRY, @POSTALCODE, @TELEPHONE, @CELL, @EMAILPERMISSION, @TEXTPERMISSION, 'OUT')

    END

@PORTALID and @USERID are passed to the stored procedure as parameters, and those values are actually saving in the insert. The columns that aren’t updating are the ones that call the GetPropertyValue function for the value. This is only on one database server (I am not connecting to a dev database through Management studio, I am connecting directly to the production database). When I execute the stored procedure from Management Studio, it’s perfect. When the trigger on the table calls the sproc, the GetPropertyValue function fails.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:07:49+00:00Added an answer on May 16, 2026 at 4:07 pm

    Get SQL Profiler on it and then copy & paste & execute the statements from that in query analyser.

    It’s likely that your production is producing subtlely different code or is injecting different param values than the ones you expect and this will catch exactly what is happening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have a stored procedure on SQL Server 2005 that accepts an XML
I have a stored procedure that returns multiple tables. How can I execute and
I have a stored procedure that returns values from a temp table. In my
I have a stored procedure that works fine on its own. A recent requirement
I currently use SQL2008 where I have a stored procedure that fetches data from
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have a stored procedure that consists of a single select query used to
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I have a Stored Procedure that rolls-back a series of operations. I want to
I have a stored procedure that needs to convert hexadecimal numbers to their decimal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.