Assigning values to variables in Stored Procedures
I am retrieving about 15 fields that I need to convert into a single plain English Description.
Here is the Select Statement:
SELECT dbo.TblRIInventory.DocFeeder AS DocFeeder, dbo.TblRIInventory.FeederModel AS FeederModel, dbo.TblRIInventory.Duplex AS DupLex,
dbo.TblRIInventory.LCT AS LCT, dbo.TblRIInventory.Cassette AS Cassette, dbo.TblRIInventory.PrintOpt AS PrintOpt,
dbo.TblRIInventory.NICOpt AS NICOpt, dbo.TblRIInventory.FaxOpt AS FAXOpt, dbo.TblRIInventory.PrintModel AS PrintModel,
dbo.TblRIInventory.FaxModel AS FaxModel, dbo.TblRIInventory.ScanOpt AS ScanOpt, dbo.TblRIInventory.ScanModel AS ScanModel,
dbo.TblRIInventory.SorterFinisher AS SorterFinisher, dbo.TblRIInventory.SorterModel AS SorterModel
FROM dbo.TblRIInventory
WHERE (dbo.TblRIInventory.ItemNumber = @ItemNumber)
(Originally I did this without the AS Statements)
Now based on the value of the entry, I wnat to include it into a variable @Description Declared nvarchar(255).
Using:
SELECT @Description = DocFeeder FROM dbo.tblRIInventory
I received the first columns data, however
Using:
SELECT @TempString = FeederModel FROM dbo.TblRIInventory
@TempString nvarchar(255)
I received Null Data.
I know that the second column has data in it.
I cannot beleive that the only way for me to get the data I need and to manipulate it is by:
SELECT @Description = DocFeeder FROM dbo.tblRIInventory WHERE dbo.TblRIInventory.ItemNumber = @ItemNumber
SELECT @TempString = FeederModel FROM dbo.TblRIInventory WHERE dbo.TblRIInventory.ItemNumber = @ItemNumber
I cannot beleive the overhead that this approach would cost. A read for every field.
Let me know if their is an alternative.
Alan
|