SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Return a RS depending on other tables existence...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 08/24/2001 :  13:02:41  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Ante writes "Hi there,

This is my problem: I have one table with rows containing languanges and their languagecode (for example: English|en ... Swedish|sv ... and so on. Almost all languages of the world in fact.). Further more I have an unspecified number of tables that holds textrows in different languages. Theese tables are named according to the languagecode in my first table (example: texts_en ... texts_sv ... ).

Now I'm about to build a dynamic dropdown-/select-menu on a webpage, that only shall contain the languages that has a table named from that languagecode. For instance, if the tables texts_sv, texts_en and texts_ru exists, I want to loop through all the languages in the language-table, check if that language text-table exists, and only return a recordset with those languages that HAS a reffering text-table. I've tried building a stored procedure doing all this and returning what i want to my ASP-page, but with no luck...

I would really appreciate your help, and I hope the above text makes any sence at all? Thank you."


United Kingdom
12543 Posts

Posted - 08/24/2001 :  13:32:27  Show Profile  Visit nr's Homepage  Reply with Quote
sounds like you need dynamic sql.
I would have though you would go to the language table to get the name of the table to get the data from.

declare @tblname varchar(128), @cmd varchar(1000)
select @tblName = tablname from languagetable where language = 'sv'
set @cmd = 'select text from ' + @tblName + ' where stringid = x'
exec (@cmd)

You can put the results of many queries into a temp table for the final result set or build up a large union query in @cmd.

Cursors are useful if you don't know sql.
Go to Top of Page

Posting Yak Master

133 Posts

Posted - 08/24/2001 :  15:50:14  Show Profile  Visit aclarke's Homepage  Send aclarke an AOL message  Click to see aclarke's MSN Messenger address  Send aclarke a Yahoo! Message  Reply with Quote
I guess I would have started out with a different schema but if it's too late for that:

select left(language, (len(language) - 3))
from LanguageTable
where right(name, 2) in (
select right(name, 2) from sysobjects where xtype='u' and name like 'texts___'

Or you could use sp_tables somehow I guess.

- Andrew.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000