• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do you query a SQL view

New Here ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

Is it possible to query a MS SQL 2005 view directly from a web page instead of querying tables in a database?

Here is our server settings: ColdFusion MX
Version  7,0,2,142559
Edition  Enterprise (DevNet)
Operating System  Windows 2003
OS Version  5.2

The view is in the same database as the original tables.

If it is possible to do, how would one go about doing it?

Thanks in advance for your assistance.

TOPICS
Advanced techniques

Views

716

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

Perhaps I misunderstand, but views are queried in exactly the same way tables are.

Explain "directly from a web page instead of querying tables in a database".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

A "view" is just a virtual table. So querying a "view" is no different than querying a physical table.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

My apologies, but I'm not very good on the database end of my knowledge base.

Basically, our database administrator set up a view for us that collects a lot of information from various tables. I need to output that information to a web page.

But the thing is, I may need to output it to multiple pages, and I didn't want to reproduce the query on multiple pages, just in case the view needs to change at some point in the future. So, I thought I would query the view. Kind of like using a cfinclude. Speaking of, I guess I can always put the actual query in a cfinclude file and call it where ever I need it, but I thought if I could query the view directly, it would save me a step.

Does that help?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 18, 2011 Aug 18, 2011

Copy link to clipboard

Copied

LATEST

So you're saying you want a query, stored someone centrally, which retrieves the data from a view. You will then use this in a few places on your site?

If so, you simply want to wrap the CFQUERY up in a CFFUNCTION inside a Component (.cfc file). Have a big of a Google about on those, you'll find countless resources which can explain it better than I can

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation