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 |
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2006-05-13 : 09:52:46
|
Hii wanna exclude some columns from my select statement. i do NOT wanna columns starting with 1,2,3,4,5 and I. How can i do it?thanks |
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-05-13 : 10:05:16
|
not sure what you mean...select columns...from tablenamewhere columnname not like '[1-5]%'--------------------keeping it simple... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-13 : 10:16:38
|
don't use select *specify the column that you want specifically in the select statement KH |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-05-13 : 12:55:39
|
DECLARE @s VARCHAR(8000)SELECT @s=''SELECT @s=@s + Column_name + ','from INFORMATION_SCHEMA.Columnswhere table_name = 'MyTbl' and Column_name not like '[1-5]%' set @s = left(@s, Datalength(@s)-1)set @s = 'Select ' + @s + ' from MyTbl'execute ( @s)Srinika |
|
|
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2006-05-13 : 16:40:16
|
thanks so much |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2006-05-14 : 13:16:10
|
Just out of curiosity....why would you not just drag/drop the columns from the object explorer, delete the ones you don't need, and call it a day. That way, you don't have to use extra resources and dynamic SQL every time you run this query.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
|
|
|
|
|