Avatar of cdemott33
cdemott33
Flag for United States of America asked on

Adding a default value to each row in a table variable

I've created a table variable and stored some value within it.  There is a column in my table called  "clientName" . Here what I need to do.

I need to set the clientName column to have the default value of 'Apple' for each row in my table.

How can I do this?

	DECLARE @myTable table
	(
		myguid int identity(1,1),
		clientName nvarchar(50),
		transactionNumber int,
		jobNumber nvarchar(500),
		eventName nvarchar(500),
		location nvarchar(500),
		tier nvarchar(100),
		movein datetime,
		startdate datetime,
		endtime datetime,
		moveout datetime
	)
		
	INSERT INTO @myTable(
		transactionNumber,
		jobNumber,
		eventName,
		location,
		tier,
		movein,
		startdate,
		endtime,
		moveout
		)		
	SELECT   
		o.transactionNumber,  
		o.jobNumber, 
		o.eventName, 
		ei.location,  
		ei.tier,  
		o.shipToDeliveryDate,
		ei.startDate,
		ei.endDate,
		ei.tearDownDate
	FROM         
		onlineOrder AS o 
		INNER JOIN 
			eventInformation AS ei 
				ON o.jobNumber = ei.jobNumber
	WHERE     
		(o.shipToDeliveryDate > '1/1/2012')

Open in new window

Microsoft SQL Server 2005Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
cdemott33

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Aneesh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
cdemott33

ASKER
That was easy!  Thank you!
Your help has saved me hundreds of hours of internet surfing.
fblack61