Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 01:24:28
|
| select namefrom railway.mdbwhere name like '#temp%'Msg 208, Level 16, State 1, Line 1Invalid object name 'railway.mdb'.How do I refer to a database? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-16 : 01:27:05
|
railway is the name of the database ?the format is [database name].[schema].[object name]try railway.dbo.mdb KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 02:01:27
|
| No its not working..Something like this is working.Select name from railway.sys.tables |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-16 : 02:40:14
|
what are you looking for ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 02:46:33
|
| I need to display tables in a particular database |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-16 : 02:55:03
|
quote: I need to display tables in a particular database
You can access sys.tables or INFORMATION_SCHEMA.TABLES for the lists of tablesselect *from [DatabaseName].INFORMATION_SCHEMA.TABLESorselect *from [DatabaseName].sys.tables quote: select namefrom railway.mdbwhere name like '#temp%'
you are looking for the temp table ? Or you want to check for the existence of a temp table ?check for object_id('tempdb..#temp_table') is not nulldon't use #temp%. It might return other temp table with similar name. example #temp1, #temp1000by the way, the temp table is created in database tempdb, not in your railway database. You can find the record in tempdb.sys.tablesif you want to reference tempdb.sys.tables use object_id()select *from tempdb.sys.tableswhere object_id = object_id('tempdb..#temp') KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sharankruthi
Starting Member
22 Posts |
Posted - 2009-07-16 : 03:13:38
|
| Thankx a lot!!! |
 |
|
|
|
|
|
|
|