Author |
Topic |
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-10-30 : 16:10:34
|
Is there a way to INSERT a new empty record without having to designate a field?I tried the obvious but they issue errors.--PhB |
|
X002548
Not Just a Number
15586 Posts |
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-10-30 : 16:22:31
|
A record with no fields filled(they're all nullable) in except the identity.--PhB |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-10-30 : 16:22:43
|
In order to insert a new record, you have to identify the fields, even if the value is NULL (provided the field allows NULLS)But at least one field would have to have a value, otherwise it would be pointless. |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-10-30 : 16:44:07
|
Insert 1 NULL into any one of the fields. If the ID is an identity that populates on trigger or such, it should work to create essentially a blank row.Insert Into Table (Field1)Select NULL |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-10-30 : 17:15:22
|
His original post asked if there was a way to do it without designating a field.You could do an insert with a bunch of NULLs as the values (by a bunch, I mean the same number of fields you have excluding the identity column). It would be easier to designate one field and insert one NULL though. This sounds like a test question to me. Maybe a bonus take home question. |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-10-30 : 17:15:40
|
OK, thanks all.--PhB |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-10-30 : 18:15:04
|
Maybe something like this?[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=90116[/url] |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2007-10-31 : 08:04:23
|
this may stisfy youmake all the fields nullableand useinsert into join1 values( null,null,null )as per i know values(,,) will never work you will have to introduce nullRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-31 : 08:17:51
|
quote: Originally posted by arorarahul.0688 this may stisfy youmake all the fields nullableand useinsert into join1 values( null,null,null )as per i know values(,,) will never work you will have to introduce nullRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA
In that case, you need to omit the identity column. So you need to explicitely specify all other columnsMadhivananFailing to plan is Planning to fail |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-10-31 : 10:14:14
|
quote: Originally posted by phrankbooth Is there a way to INSERT a new empty record without having to designate a field?I tried the obvious but they issue errors.--PhB
Not that i can figure out. You must specify at least ONE field on the insert. How about, read the links in my sig, and restate your question?[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
|
|
pgedney
Starting Member
1 Post |
Posted - 2008-03-16 : 05:04:21
|
This will work in SQL Server,... meeting all criteria of the original post.1) Insert a blank record2) Statement requiring no Value ArgumentsThis syntax also triggers all default values.--------------------------------------insert into TableName Default values--------------------------------------I tried it and it worked! |
|
|
|