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 957467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:42:21+00:00 2026-05-16T00:42:21+00:00

Please help me with this: This code works fine except for cases in which

  • 0

Please help me with this:

This code works fine except for cases in which the control goes inside the IF block of “NOT EXSISTS”, then any query run after the execution of this block causes the sql connection to forcibly get closed, although the results from the running of this code block are correct. I can not run other queries after running it.

IF(@Mode='Get')
BEGIN
    IF(@Field='manager')
    BEGIN
        DECLARE @UserUserName NVARCHAR(250)
        DECLARE @UserID AS VARCHAR(50)
        SELECT @UserUserName=CAST(Value AS NVARCHAR(250)) FROM dbo.UserProperties WHERE [Key]=@Key AND Field='manager'
        IF(NOT EXISTS(SELECT * FROM dbo.Users WHERE UserUsername=@UserUserName) OR @UserUserName IS NULL )
        BEGIN
            SELECT  @UserID = dbo.fnGetManagerId(CAST(@Key AS INT)) -- numeric
            SELECT @UserUserName=UserUsername FROM dbo.Users WHERE UserID=@UserID
        END 
        SELECT UserName AS Value FROM users WHERE UserUsername=@UserUserName
    END 
    ELSE
    BEGIN
        SELECT Value FROM dbo.UserProperties WHERE [Key]=@Key AND Field=@Field
    END 
END
  • 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-16T00:42:22+00:00Added an answer on May 16, 2026 at 12:42 am

    I seem to remember seeing kb articles about bugs with scalar UDFs in SQL2000 that could cause access violations maybe you’ve hit one of those? I’d first separate the cast from the UDF parameter list and do it in another line

    Replace

    SELECT  @UserID = dbo.fnGetManagerId(CAST(@Key AS INT)) -- numeric
    

    With

    DECLARE @K int
    SET @K = CAST(@Key AS INT)
    SELECT  @UserID = dbo.fnGetManagerId(@K)
    

    then if the problem persists comment out a line at a time until you find the culprit.

    I’d look in the SQL Server Error Logs. Also you can use SQL Profiler to trace user error messages. A high enough severity error would close the connection automatically.

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

Sidebar

Related Questions

Please i need help, this code below works fine on my localhost, php5.3+ but
Could anyone please help me convert this code to vb.net, I have tried it
Could you please help me converting this c++ code into python: I am trying
Hey friends any one please help me for this issue.in this javascript code i
Please, help me. I dont know what is wrong with this code: import android.appwidget.AppWidgetProvider;
This code works fine in <= IE7, but it doesn't work in firefox ..
I've used this code in another site I've made and it works absolutely fine
Now All of this code works fine in Firfox but in IE the divs
This code works fine and produces checkbuttons in a long long list. def createbutton(self,name):
Please help me to fix this... i have a link with the code http://jsfiddle.net/LTYa2/14/

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.