August 17, 2007 at 7:31 am
CREATE
TABLE #tbls (
tbl_name
SYSNAME
)
exec
sp_msforeachtable 'IF (SELECT COUNT(*) FROM ?) > 0 INSERT #tbls SELECT ''?'' '
SELECT
* FROM #tbls ORDER BY tbl_name
when i use this query i get full table name like [empuser].[employees]
how can i get just table name as employees
August 17, 2007 at 7:57 am
You can do a update before the select
UPDATE
#tbls SET tbl_name = REPLACE(tbl_name,'[empuser].','')
August 17, 2007 at 8:02 am
but still i cudnt replace [ ] for table name.
I need just employees instead of [employees]
August 17, 2007 at 8:20 am
UPDATE
#tbls SET tbl_name = REPLACE(REPLACE(REPLACE(tbl_name,'[empuser].',''),'[',''),']','')
August 17, 2007 at 3:34 pm
SELECT O.Name
FROM sysobjects O
INNER JOIN sysindexes I ON I.ID = O.ID AND I.indid in (0, 1)
WHERE O.xtype = 'U' AND I.rowcnt > 0
BTW, you may have 2 or more tables with the same name but different owners.
_____________
Code for TallyGenerator
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply