Inserting  a value and a constand

Posted on 2004-10-28
Last Modified: 2012-08-13

I am writing a procedure, in it I need to write an INSERT that will add all the values in one column (found in a query) and then the other column needs to have a variable (@NTUserNames) in it.

Question by:itsallmeman

    Author Comment

    To simplify my question
    I need a query that returns a constant, something like:
    SELECT 'HELLO', Field1  FROM Table1
    But how would I go about it if HELLO was in a variable?
    LVL 17

    Accepted Solution

    SELECT @HELLO, Field1  FROM Table1
    LVL 26

    Expert Comment

    If you need to use the resultset in another place (front-end, another query, ...), you also need an alias (a column name)

    select @Hello AS FindMeADecentName, Field1 from ...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    In this article—a derivative of my blog post (—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now