473,421 Members | 1,531 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,421 software developers and data experts.

The select statement is in a field

Ok, I inherited this database and there is a field that stopres a select
statement. Is there anyway possible to execute the value of the field
within a select statement?

For example:

the table:
Name "george"
lookupForName "Select orders from Ordertable"

So maybe something like select name, execute(lookupforname) as orders

Sorry, I didn't design this, just inherited :)

george
Aug 31 '05 #1
1 1212
George o (ge*****************@hp.com) writes:
Ok, I inherited this database and there is a field that stopres a select
statement. Is there anyway possible to execute the value of the field
within a select statement?

For example:

the table:
Name "george"
lookupForName "Select orders from Ordertable"

So maybe something like select name, execute(lookupforname) as orders


You would have to do something like:

SELECT @sql = lookupforname FROM tbl WHERE name = 'george'
EXEC(@sql)

If you really want to add another column to that result set, it may get
ugly. If the SELECT statements does not have a WHERE clause you could
add "CROSS JOIN (SELECT name = ''george'')". Else you have to splice
it in into the query.

For more information on dynamic SQL, see this article on my web site:
http://www.sommarskog.se/dynamic_sql.html.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Aug 31 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ghasem | last post by:
Dear mySQL community, I have once again turned to the user groups for a problem I cannot solve myself! Atually, I have read all I can from the newsgroups on this but I could not solve it myself....
2
by: Edwinah63 | last post by:
Hi Everyone, All the very best for 2004!! i need urgent help with this problem, the users are about to skin me alive!! we have an access front end with linked to sql server 2k tables. ...
1
by: John Hall | last post by:
We need to read a SQL database containing a mix of English words and Chinese Characters. We think we need to use the N'xxxx' to read the Unicode. We have one place where the SELECT statement...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
5
by: freddy | last post by:
I have a select statement like this: string Select = "Select TableofContents, DataOwner, Delegates From NYC"; and it work fine, but if I was to put a space in like this: string Select = "Select...
1
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
0
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
1
by: canugi | last post by:
I need to store the contents of an SQL "in clause" in an MS Access 2000 table. I use MS Access version 9.0.8960 (SP3) This is my statement (and it works fine with the explicit "in clause"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.