Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting columns during a SELECT
Message
From
22/12/2008 09:09:30
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Setting columns during a SELECT
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01369088
Message ID:
01369088
Views:
53
Hi All,

I am creating a stored procedure that selects a subset of records from a table. I would like to set the value of three columns when I make the selection. How can I do this? Here is my stored procedure.
CREATE PROCEDURE dbo.GetSpotsByCompanyIDWithRange
(
	@CompanyID UniqueIdentifier,
	@StartRange DateTime,
	@EndRange DateTime,
	@Sentinel Bit,
	@SentinelMark VarChar
) 
AS
BEGIN
	SET NOCOUNT ON;

	SELECT     s.Track_Id,
		s.CompanyID,
		s.TruckID,
		t.TruckCode,
		s.DriverID,
		s.Truck_Ip,
		s.IsTip,
		s.Spot_Message,
		s.Route_Day,
		s.Route_Number,
		s.Municipality,
		s.Upload_Id,
		s.Spot_Latitude,
		s.Spot_Longitude,
		s.Spot_Heading,
		s.Spot_Speed,
		s.Spot_Altitude,
		s.Spot_Time,
		s.Spot_Status,
		s.Sentinel,
		s.Record_Status,
		s.Record_Status_dt
	FROM TrackSpot s, TruckAccess t
	WHERE s.TruckID = t.TruckID
		AND s.CompanyID = @CompanyID
		AND Spot_Time >= @StartRange
		AND Spot_Time <= @EndRange
		AND Sentinel = @Sentinel

END
GO
I want to set the following fields that are included in this selection.
s.SentinelMark = @SentinelMark
s.Record_Status_dt = DateTime.Now.ToUniversalTime
s.Record_Status = "Sentinel Marked"
Timothy Bryan
Next
Reply
Map
View

Click here to load this message in the networking platform