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 |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2012-10-09 : 18:07:20
|
Hi friends,I have a table customer with following columns A,B,Call jumbled upSo when i use the query select * from CustomerThe results show up as this B A C but i want them to be displayed in order..is that doable?Thank you |
|
lazerath
Constraint Violating Yak Guru
343 Posts |
Posted - 2012-10-09 : 18:33:12
|
Just do this:SELECT A,B,C from Customer In fact, you should avoid SELECT * in almost all production level code. The one case where it is acceptable is with EXISTS. |
 |
|
Mike Jackson
Starting Member
37 Posts |
Posted - 2012-10-10 : 08:52:41
|
If you have a bunch of columns you could do this....declare @table as varchar(50)set @table='YourTable'declare @test as varchar(5000)select @test= COALESCE(@test + ', ', '') + [Name]from sys.columnswhere object_id like ( select Object_id from sys.tables where name=@table )select @test= 'Select ' + @test + ' from ' + @tableprint @testexec (@test)MJ |
 |
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2012-10-11 : 11:34:32
|
Thank you lazerath and mike..Really appreciate it.. |
 |
|
|
|
|