Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Other Development Tools
 URL QueryString in SQL FROM clause?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

brandt719
Starting Member

2 Posts

Posted - 02/02/2007 :  13:01:15  Show Profile  Reply with Quote
Is it possible to pull a URL QueryString into the FROM clause of a SQL statement? I have an ASP page that has a drop-down list of names of people in a particular group. Now, I would like for the drop-down list to pull a NEW group of folks from another table IF a particular URL Querysting is present. For example: www.mysite.com/default.asp?GroupID="ZTA". Is this possible? I use url querystrings in WHERE clauses, but I get a syntax error when I try to use it in a FROM clause. I appreciate any advice you could give me. Thanks

snSQL
Flowing Fount of Yak Knowledge

USA
1837 Posts

Posted - 02/02/2007 :  14:49:47  Show Profile  Reply with Quote
It is possible, you'd need to use dynamic SQL, basically construct the query by concatenating the name of the table into the SQL query.

However, it's not the best way to do it. Are those tables really all completely different, or are they very similar, just holding different groups of people/things/whatever? If they are similar, then create one table that holds them all, and add a type column that holds the value to determine the right group and then select the group in the WHERE clause as you've been doing. Unless the things in the different tables really represent different kinds of entities, this should be a much better design.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000