471,108 Members | 1,263 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

Simple SQl question

I am trying to create a SQL statement that returns values from fields
in the database but I also need to return values that are NOT in the
database but hard coded int he SQL statement. The values along with the
names of the fields will be hardcoded into the SQL statement. I'm not
sure if this can be done.

It will be something like this:

SELECT vchrFirstName,
vchrLastName,
'hardcoded value' AS myField
FROM tblCustomer

The above statement does NOT work. It throws an error, but that is what
I am trying to do. Bascially I want the query to return the values for
vchrFirstName and vchrLastName which are in the database, but I also
want the field called "myField" to be returned in the recordset with
the value of "hardcoded value" for every record returned. I hope this
made sense and can be done. THANKS!

Dec 29 '05 #1
3 957
Rob
Erich93063 wrote:
I am trying to create a SQL statement that returns values from fields
in the database but I also need to return values that are NOT in the
database but hard coded int he SQL statement. The values along with the
names of the fields will be hardcoded into the SQL statement. I'm not
sure if this can be done.

It will be something like this:

SELECT vchrFirstName,
vchrLastName,
'hardcoded value' AS myField
FROM tblCustomer

The above statement does NOT work. It throws an error, but that is what
I am trying to do. Bascially I want the query to return the values for
vchrFirstName and vchrLastName which are in the database, but I also
want the field called "myField" to be returned in the recordset with
the value of "hardcoded value" for every record returned. I hope this
made sense and can be done. THANKS!


Yes, it can be done, and your query should work. What's the error
you're getting?
Dec 29 '05 #2
OK, I must have been doing somethign else wrong, because now it's
working. It's working the way I did it in my post. Not sure what I did
wring before. hmmm THANKS

Dec 29 '05 #3
Hi

At a guess you have SET QUOTED_IDENTIFIER ON and you are using double
quotes?

John

"Erich93063" <er********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
OK, I must have been doing somethign else wrong, because now it's
working. It's working the way I did it in my post. Not sure what I did
wring before. hmmm THANKS

Dec 29 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Patchwork | last post: by
1 post views Thread by Proteus | last post: by
2 posts views Thread by Raskolnikow | last post: by
3 posts views Thread by Peter | last post: by
7 posts views Thread by abcd | last post: by
14 posts views Thread by Giancarlo Berenz | last post: by
30 posts views Thread by galiorenye | last post: by
10 posts views Thread by Phillip Taylor | last post: by
17 posts views Thread by Chris M. Thomasson | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.