473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How do I Set a defined variable = fieldname?

49
Newbee SQL question, how do I set a variable = field name? getting Msg 207 error on the Set line below.

Expand|Select|Wrap|Line Numbers
  1. declare @TempProduction as int,
  2.         @TempTimeStamp as date,
  3.         @TempQuality as int,
  4.         @TempMachineName as varchar(50)
  5. select
  6. Production,
  7. TimeStamp1,
  8. Quality,
  9. MachineName,
  10. @TempProduction
  11. From dbo.testwide
  12. where MachineName = 'a'
  13. set     @TempProduction = Production
  14. --        @TempTimeStamp = TimeStamp1,
  15. --        @TempQuality = Quality,
  16. --        @TempMachineName = MachineName
  17. --from dbo.testwide
  18.  
When I use an integer, say 26, instead of the field name "Production" I do not have an error.
Jan 4 '12 #1

✓ answered by ck9663

Here, read this...

Happy Coding!!!


~~ CK

1 1406
ck9663
2,878 Expert 2GB
Here, read this...

Happy Coding!!!


~~ CK
Jan 4 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: N. David | last post by:
In bash, you can include a variable as part of a filename. For example: date=$(date) cat log.txt > $date"_log.txt" Which, when setting the right options in date, creates a file named...
6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
3
by: lallous | last post by:
Usually you can check for a defined variable as: #ifdef DEF1 // do stuff here #endif Can I test if a function is defined then do things, example: int myFnc() { // blah blah }
6
by: rong.guo | last post by:
Hello, I am trying to update variable 'Type' (which is a pre-defined variable without any value in it). Is there a way to combine Step1 to Step3 into one single Update? I tried the query at the...
3
by: Miso Hlavac | last post by:
Hello, I need to create user defined variable in every database session. In Sybase ASA is equivalent: CREATE VARIABLE name TYPE; I need use this in views. Is it possible??? thanx, miso
8
by: eros | last post by:
//page1.php <?php include('pagebase.php'); ?> //pagebase.php <?php echo __CALLING_FILE__; // outputs the previous php file. 'page1.php' ?>
5
by: jjeanj1 | last post by:
I am having issue using a user defined variable i an a mysql statement. here is the issue that i am facing: i have a variable called $date in php.This variable is assigned a valued from a dropdown...
3
by: anniebai | last post by:
In myTable, there're several columns as Avg1, Avg2 ....Avg92, they all are float type. in my SQL code: declare @counter int declare @parm nvarchar(20) set @counter=0 while @counter<10
3
by: govind161986 | last post by:
I am creating a stored procedure which has multiple joins. Now the problem is I want some joins to be executed for a given condition and some other join for other condition. For example select...
3
by: bharathpaul | last post by:
Hi, I am using Python 3.1.1. In perl we can use defined($variable name) to check whether a variable is defined previously or not.. I am looking for a function in Python which is used to check...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.