Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert a row with default values

Author  Topic 

Patyk
Yak Posting Veteran

74 Posts

Posted - 2014-08-12 : 19:55:55
I need to insert a record in a table which has about 90 columns.

My first column is a CustCode that would be supplied by parameter all other columns should be set to 0

Is there a quick way of doing this?

Thanks

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-12 : 21:28:36
[code]
insert into myTable (CustCode)
select @CustCode
[/code]

This assumes that all other columns have default values or can accept NULL values.
Go to Top of Page

Patyk
Yak Posting Veteran

74 Posts

Posted - 2014-08-14 : 12:17:52
this will insert the record, my CustCode is OK, all other columns are null. I want them to be 0 instead. There are many columns all should be Zero.
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-14 : 12:25:27
Then, you'll have to specify them all if they don't have defaults.
Go to Top of Page

Patyk
Yak Posting Veteran

74 Posts

Posted - 2014-08-14 : 12:28:31
Could there may be a loop for column 1 to the end insert Zero?
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-14 : 12:37:04
no
Go to Top of Page
   

- Advertisement -