Groups | Blog | Home
all groups > sql server (microsoft) > december 2006 >

sql server (microsoft) : inserting "0" to all fields.


Ed Murphy
12/5/2006 3:54:55 AM
[quoted text, click to view]

Are you sure you're not violating 1NF?

http://en.wikipedia.org/wiki/1NF#Multiple_columns_representing_the_same_type_of_fact

[quoted text, click to view]

Surely this is overkill. Just format the statement something like this:

insert into table (
col01, col02, col03, col04, col05,
col06, col07, col08, col09, col10,
col11, col12, col13, col14, col15,
col16, col17, col18, col19, col20,
col21, col22, col23, col24, col25,
col26, col27, col28, col29, col30
) values (
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
User
12/5/2006 9:42:47 AM
Hi,

I have a table with 30 columns.

I want to insert a value of "0" into the columns

I do not wish to do a

insert into table (col1,col2,col3.....col3) values(0,0,0,0,0,0,......0)

as it is a very painful process. One comma missing and it's going to hurt my
eyes.

Are there any short cuts to do the above: insert "0" to all the columns to a
new row?

pls advise,

Thanks



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
BC
12/10/2006 10:08:44 AM
You could use replicate and copy the output for your select.

select replicate('0,', 30)

Will return
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

Remove the last comma
[quoted text, click to view]
BC
12/10/2006 10:09:30 AM
You could use replicate and copy the output for your select.

select replicate('0,', 30)

Will return
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

Remove the last comma
[quoted text, click to view]
AddThis Social Bookmark Button