Solved

Inserting  a value and a constand

Posted on 2004-10-28
224 Views
Last Modified: 2012-08-13
Hi,

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.


Cheers
0
Question by:itsallmeman
    3 Comments
     

    Author Comment

    by:itsallmeman
    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?
    0
     
    LVL 17

    Accepted Solution

    by:
    SELECT @HELLO, Field1  FROM Table1
    0
     
    LVL 26

    Expert Comment

    by:Hilaire
    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 ...
    0

    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 DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—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