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 |
|
robertino
Starting Member
2 Posts |
Posted - 2010-05-25 : 22:11:02
|
| i have a number of tables in my database but the table names are either ended with xxx_male or xxx_female.how do i construct a select SQL statement so that i only select all the tables with name ended without "_female"?please note that this is a little bit different from the select SQL statement that retrieving all tables with name ended with "_male". this is because in future i might want to have other table name (with different format). so i need to have the SQL statement that select table names without ending with "_female".please help me. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-05-25 : 23:21:21
|
| Is this you are looking for ?select * from sysobjects where type ='U' and name not like '%[_]FEMALE'select * from sysobjects where type ='U' and name not like '%[_]MALE'Regards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2010-05-25 : 23:23:01
|
| I assume that you want to select the table names,SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']'AS SchemaTable FROM sys.tables where name not like '%_female'SQL Server Programmers and Consultantshttp://www.sql-programmers.com/ |
 |
|
|
robertino
Starting Member
2 Posts |
Posted - 2010-05-25 : 23:53:03
|
| thanks...great, fantastic. |
 |
|
|
|
|
|