Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Inserting  a value and a constand

Posted on 2004-10-28
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 12432582
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

BillAn1 earned 200 total points
ID: 12432654
SELECT @HELLO, Field1  FROM Table1
LVL 26

Expert Comment

ID: 12432682
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 ...

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

636 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