[dba-SQLServer]UNION Columns?

Susan Geller sgeller at cce.umn.edu
Mon May 5 15:15:56 CDT 2003


Re the create table:  just like you would with anything else:  

create  procedure dbo.MySproc
as

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MyTable]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[MyTable]

Create table dbo.Mytable
	([table_name] [varchar](100) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
	[column_name] [varchar](100) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
	etc for rest of fields
	)

Select table_name, column_name, etc
>From information_schema.columns

Go


Re the name:  The algorithm definitely doesn't work for all names.  No
matter the change, it's a brave thing to do and I can certainly
understand how a person would cop out.  It's been hard for me and I'm
the one who is expected to change my name and the change is only one
letter!  

--Susan


-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com] 
Sent: Monday, May 05, 2003 2:36 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]UNION Columns?


Ok recently married smartypants :-), how would I turn the resultset into
a create table statement?

BTW, I love your idea of both persons changing names. Unfortunately, I
didn't at the time have your nerve. I married a woman whose surname is
Ruskin (c.f. John Ruskin; they are related and I read everything he
wrote long before meeting Samantha). And I wanted to change my name to
Ruskin but copped out at the last moment :-(

Given your algorithm, this might have led to:

A) fullskin (nah, don't wanna go there)
B) ruskler (sounds like some a cattle thief)

The aforementioned John was the principal champion of Turner, my fave
painter in the world. I shoulda just grabbed her name and been done with
it.

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan
Geller
Sent: May 5, 2003 2:58 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]UNION Columns?


select table_name, column_name, data_type, is_nullable,
character_maximum_length 
from information_schema.columns;

Try a select * to see what other goodies you can get!

--Susan


-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com] 
Sent: Monday, May 05, 2003 1:52 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]UNION Columns?


That works well, and thank you for that. Just one more question
(actually
two): where to get the column size and where to get the NOT NULL or
whatever?

A.

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy
Pang
Sent: May 5, 2003 2:11 PM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer]UNION Columns?


select table_name, column_name, data_type from
information_schema.columns;

HTH
Billy


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com



More information about the dba-SQLServer mailing list