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
7 comments:
Nice trick, I don't know why I didn't find out about it before.
Thats the best trick, ever!
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.
Thanks allot for that one ! :)
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.
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.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
CREATE PROCEDURE [dbo].[collist] @tab varchar(128), @heads varchar(128) = ''
as
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
begin
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
begin
if datalength(@nm) > 0
select @str = @str + ', ' + @heads + @nm
fetch next from mc into @nm
end
close mc
deallocate mc
select 'Columns' = @str
end
Thank you for the nice little trick. That helps a lot. I wonder how to drag the column from Sybase SqlAnywhere. Would really appreciate it if you can come up with another trick for that.
Post a Comment