Google Interview Questions | SQL Server Software | Microsoft SQL Server Books | Denis Gobo's personal blog | Pro SQL server 2005 (Apress)
Top 10 Articles | Add Yourself To My Frappr Map | Ken Henderson Interview | Louis Davidson Interview

Thursday, September 22, 2005

Query Analyzer Trick

In Query Analyzer you can save a lot of time by using this trick instead of typing all the column names of a table
Hit F8, this will open Object Browser
Navigate to DatabaseName/TableName/Columns
Click on the column folder and drag the column folder into the Code Window
Upon release you will see that all the column names are in the Code Window


Blogger Joe Muka said...

Hi, Nice site. My small site about low carb recipes is sometimes a pain to keep up with and needs work. Good job!

5:20 AM  
Anonymous Anonymous said...

Nice trick, I don't know why I didn't find out about it before.

11:35 AM  
Anonymous Anonymous said...

Thats the best trick, ever!

6:17 AM  
Anonymous Anonymous said...

Maybe if Joe spent more time maintaining his site rather than promoting it in irritating ways, it wouldn't be such a pain for him to keep up with.

2:54 PM  
Anonymous Anonymous said...

Thanks allot for that one ! :)

11:18 AM  
Anonymous Anonymous said...

Unfortunately it doesn't enclose the column names in square brackets, so when you have column names with spaces or special characters you have to manually correct them.

1:26 AM  
Anonymous Anonymous said...

Nice trick -- how does one find stuff like this. I had to write a stored procedure, but it is a little more flexible: you can add a string to the beginning of each column name.

CREATE PROCEDURE [dbo].[collist] @tab varchar(128), @heads varchar(128) = ''
declare @i as int
declare @tid as int
declare @nm as varchar(128)
declare @str varchar(8000)
select @tid = object_id(@tab)
if @tid is not null
declare mc cursor for
select '[' + name + ']' from sys.syscolumns
where id = @tid
order by colorder
open mc
fetch next from mc into @nm
if datalength(@nm) > 0
select @str = @heads + @nm
fetch next from mc into @nm
while @@fetch_status <> -1
if datalength(@nm) > 0
select @str = @str + ', ' + @heads + @nm
fetch next from mc into @nm
close mc
deallocate mc
select 'Columns' = @str

3:40 PM  

Post a Comment

<< Home