Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL teaser DEFAULT WITH VALUES

Status
Not open for further replies.

SQLDenis

Programmer
Oct 1, 2005
5,575
US
without running this what will be the values of the ID2 column after creating a default with values?
Code:
create table def(id int ,id2 int)
INSERT def (id) VALUES(1)
INSERT def (id) VALUES(2)
INSERT def (id) VALUES(3)


SELECT * FROM def


ALTER TABLE def ADD CONSTRAINT
	Dflt DEFAULT 500 FOR id2 WITH VALUES



INSERT def (id) VALUES(4)

[b]--what will be the values here[/b]
SELECT * FROM def


DROP TABLE def

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
SQLBlog.com, Google Interview Questions
 
The first insert will have null values for id2.
The second insert will have 500

- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
null
null
null
500

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top