A third party vendor has a table with a field name of "desc" in it. Since "desc" is a reserved term in SQL Server 2005 how does one query Table.Desc ?
when you try it with table.desc it errors since it turned blue being a reserved word.
Jeff
try table.[desc]|||I did this and it would not create the column. I have tried:
table.[desc]
[table].[desc]
Neither of which worked.
Jeff
|||I just ran this code in sql 2005:
create table #tmp( [desc] varchar(10))
insert into #tmp values( 'one')
select #tmp.[desc] from #tmp
Is your table actually named "Table"?
|||Even if your table is called “table” you should be able to query it.
For example,
create table [table]([desc] char(10))
go
insert into [table] values ('test')
go
select [desc] from [table]
go
When you said it did not work, what was the error message? What is the version of SQL Server are you using?
Consult this Books Online topic http://msdn2.microsoft.com/en-US/library/ms176027(SQL.90).aspx for more information.
HTH,
Boris.
|||There wasn't an error, it just didn't show the desc column in the resultset grid.
ALTER PROCEDURE [dbo].[SUR_GiftsDetail]
@.StartDate DateTime,
@.EndDate DateTime
AS
BEGIN
SET NOCOUNT ON;
SELECT
ItemID,
Quantity,
TourID,
TourNumber,
MasterID,
Description
MasterCatID,
CategoryID,
CategoryDescription,
Arrival,
Depart,
BookingID,
it_arrival_date
FROM
(SELECT
Booking.bk_id AS BookingID,
i.it_arrival_date AS Arrival,
i.it_arrival_date,
i.it_id AS TourNumber,
i.it_arrival_date + i.it_nights AS Depart,
pt.fk_itemid AS ItemID,
pt.Qty AS Quantity,
pt.fk_tourid AS TourID,
pm.ItemID AS MasterID,
pm.[desc] AS Description,
pm.fk_categoryID AS MasterCatID,
pc.categoryID AS CategoryID,
pc.[Desc] AS CategoryDescription
FROM
Booking
LEFT JOIN ITINERARY i ON Booking.bk_id = i.fk_bk_id
LEFT JOIN pi_transactions pt ON pt.fk_tourid = Booking.bk_id
LEFT JOIN pi_master pm ON pm.itemid = pt.fk_itemid
LEFT JOIN pi_category pc ON pc.categoryid = pm.fk_categoryid
LEFT JOIN pi_transactions ptt ON ptt.fk_itemid = pm.itemid
WHERE
i.it_arrival_date BETWEEN @.StartDate AND @.EndDate AND i.fk_et_entity_type LIKE 'Hotel') AS derivedTour
WHERE
it_arrival_date BETWEEN @.StartDate AND @.EndDate
ORDER BY
TourID
END
All the columns show except for the two desc fields.
SQL Server 2005
Jeff
|||Hi
You are missing a comma after Description in the outer SELECT list.
No comments:
Post a Comment