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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:34:00+00:00 2026-05-16T22:34:00+00:00

I am trying to modify a stored procedure I wrote to pull data from

  • 0

I am trying to modify a stored procedure I wrote to pull data from other tables and insert it to a table.

Basically I have one table where we store mappings by ID. In that table I put together a field that should be storing the concatenation of that data, which works fine. The problem is it is storing the ID of the mapping, not the name that belongs to that ID.

My Stored Proc:

`USE [SNHULeads]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[spSNHUCodeCreate]
(
@Source numeric(18,0),
@ProgramName numeric(18,0),
@Division numeric(18,0),
@Medium numeric(18,0),
@content varchar(50),
@URL varchar(500) = 'N/A',
@redirect varchar(100),
@Cost numeric(18,0),
@Notes varchar(500) = 'N/A',
@StartDate datetime,
@EndDate datetime,
@oper varchar(50),
@id varchar(50)
)

AS

DECLARE @SNHUCode numeric(18,0)
DECLARE @DateCreated datetime 
SET @SNHUCode = (SELECT MAX(snhuCODE) + 1 FROM [dbo].[VendorProgram])
SET @DateCreated = GETDATE()`

IF @URL != 'N/A'
BEGIN
    SET @URL = 'http://www.snhu.edu/' + @URL + '.asp?utm_source=' +    CONVERT(varchar(50), @Source) + '&utm_medium=' + CONVERT(varchar(50), @Medium) + '&utm_content=' + CONVERT(varchar(50), @content) + '&utm_campaign=' + CONVERT(varchar(50), @ProgramName) + '&SNHU_Segment=' + CONVERT(varchar(50), @Division)
END

INSERT INTO [SNHULeads].[dbo].[VendorProgram]
       ([vendorID]
       ,[programID]
       ,[divisionID]
       ,[mediumID]
       ,[snhuCODE]
       ,[content]
       ,[url]
       ,[cost]
       ,[Notes]
       ,[StartDate]
       ,[EndDate]
       ,[redirect]
       ,[DateCreated])
 VALUES
       (@Source
       ,@ProgramName
       ,@Division
       ,@Medium
       ,@SNHUCode
       ,@content
       ,@URL
       ,@Cost
       ,@Notes
       ,@StartDate
       ,@EndDate
       ,@redirect
       ,@DateCreated)`

Basically, with the URL column, I am catching the IDs I send in, which is not what I want. I cannot seem to find a way to select the name that corresponds to the @Source ID I send in.

I tried something like, declaring a new variable in the proc, and then selecting it like this:

DECLARE @sourceName varchar(50)
SET @sName = (SELECT Leads.dbo.Vendors.Source WHERE mappingID = @Source)

That gives me an error, “The multi-part identifier “Vendors.mappingID” could not be bound.”.

Any help out there for me? Don’t bash the SQL too much, it’s obviously not my strong point.

  • 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-16T22:34:01+00:00Added an answer on May 16, 2026 at 10:34 pm

    Ok I can’t be sure this is what you want but assuming that @source relates to the column MappingId in a table called Vendors in a Database called Leads; then this SQL will set a variable called @sourceName to the corresponding Source Name. You can then Insert this data in to another table.

    Is this what you were looking for?

        Declare @sourceName varchar(50)
    
        Select @sourceName = SourceName
        From Leads.dbo.Vendors
        Where MappingId = @Source
    

    Note: This SQL assumes that only one row will exists for each @source passed in.

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

Sidebar

Related Questions

I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
I'm trying to modify the class of an element if an ajax call based
I am trying to modify the output stream to search/replace some XHTML tags returned
I'm currently trying to modify some HttpWebRequest functions, but I can't do it through
I'm trying to modify the contents of an MSI file using Powershell. To do
I'm trying to modify the UI of a Redmine installation (Redmine 0.7.3.devel.2093 (MySQL)). When
I'm trying to determine how to modify SAP R/3 package code of an installed
Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to get my css / C# functions to look like this: body {
Trying to find some simple SQL Server PIVOT examples. Most of the examples that

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.