SQL Server >> Any easy way of getting a columnlist for use with an INSERT statem

by Steen Persson » Mon, 13 Sep 2004 22:21:32 GMT

Thanks....that was just what I wanted.


Regards
Steen


David Portas wrote:
> If you are using SQL2000 you can drag the list of column names from
> the Object Browser in Query Analyzer. Just click on the word
> "columns" in the tree and drag it into the editing window.
>
> --
> David Portas
> SQL Server MVP




Similar Threads

1. Any easy way of getting a columnlist for use with an INSERT statement - SQL Server

2. any easy ways to pick up SSIS ?

I've spent a couple days going over online book on SSIS. It looks too
complicated. Is this just me or others feel the same way?
is there any good book or tutorial out there?

Thanks

Ken

3. Two ways of getting a maximum value... - SQL Server

4. Specify the default year in a time dimension used in several ways in a cube

Hi

I have a time dimension, DimTime (including Year, Quarter, Month and
Day), that is used in several ways in the Cube (Financial date, Due
date). I want to set the default value for the Year to be the current
year (2007).

I have tried to set the DefaultMember property for the [Year Number]
attribute to StrToMember("[DimTime].[Year Number].
["+str(DatePart("YYYY",Now()))+"]")

The problem shows when I try to process the cube using the Time
dimension. I get this  error

"Error	1	The specified default member '[Financial Date].[YQMD].
[Year].&[2007]' must be from the '[DimTime].[Year Number]' hierarchy.
"


Does this mean that I can have only one usage of the Time dimension in
the cube?
If not how can I set the DefaultMember property for the Time dimension
so it will work for all the usages of the Time dimension in the cube?

Thanks in advance

5. Ways for using .Net Assembly within a Reporting Services report - SQL Server

6. (Hopefully) Easy SQL 6.5 Question - Getting Table Structure

Hi All

I need to tell a colleague how to get the structure (table name +
column names + primary key + index etc) of each table in a SQL 6.5
database.

I can't access the server as it is on another site several 100's of
miles away, so I need step by step destructions on how to do it. I'm
not that hot at SQL and my colleague is even worse so really clear
instructions would be appreciated.

Many Thanks

Taddub

7. Getting error when getting data from MSaccess using ODBC

8. Building ColumnList - Which one is Optimized

Hi guys
I need to build a columnlist of a set of 2000 table
I have a temporary table TableAndColumnNames  with this structure
                        Table_Name,Column_Name,Ordinal_posito
This I populate from the Information schema.columns

The data is something like this
Authors   email_id     
Authors   emp_id       
Titles      emp_id       
Titles      emp_name  

I have one more temporary table TableColumnLists and the structure is like thi
TableName Column_nam

The data should be something like this
Authors  email_id,emp_i
Titles     emp_id,emp_nam

which I have to populate either by method 1 or method 2 given below

Method 1

SELECT @ColumnList =  @ColumnList + column_name + ','
FROM TableAndColumnName
WHERE  table_name = @TableNam
order by ordinal_positio

Update TableColumnList
set Columnname = @ColumnList
where Table_name = @TableNam

Method 2

UPDATE 
   SET t.ColumnNameList = t.ColumnNameLis
     + CASE WHEN t001.ColumnName IS NULL THEN '' ELSE (       t001.ColumnName) EN
     ........
     ........
     ........
     + CASE WHEN t100.ColumnName IS NULL THEN '' ELSE (', ' + t100.ColumnName) EN
  FROM TableColumnLists AS 
  LEFT JOIN TableAndColumnNames AS t001 ON ((t001.TableName = t.TableName) AND (t001.ColumnOrder = 001)
     ........
     ........
     ........
  LEFT JOIN TableAndColumnNames AS t100 ON ((t100.TableName = t.TableName) AND (t100.ColumnOrder = 100)

My assumption

For method 1 if there are about 1000 table there will be 1000 updates will be executing inside the loop
For method 2 the no. of update statement is decided by the max no of column names. Eventually it will be only
one update

My question is ......
will the  No. of updates a performance hit 
Will the No of joins a  performance hit 

Pls correct me which one is the best way to do 

Thanks
Ganes