Can't get Returned Values

This is something that I have never worried about but I think it may be the key to a problem I am having. i.e. I am having problems with No Returned Values.

I have a table “Doctors2”. There is a field CName2 that has the name of a doctor and the title. e.g. William Walters, Oncologist.

I am using the code below to extract one name and title. This is to be given a variable name @Dname.

SELECT CName2 INTO @Dname FROM Doctors2 limit 1;

But the response is “No Returned Value”.

I need to put this value into localStorage. I am guessing that the problem of no returned value is probably why the Success Event. Local Storage is not working.
What am I doing wrong here?

Mike

Hey @mdsmith1!

I do not believe you can SELECT INTO a variable in this way without first declaring it and then updating it. Is @Dname supposed a temporary table or just a variable for future code processing?

If it is a table you should INSERT:

DECLARE @Dname TABLE
(
   NameAndTitle nvarchar(100)
);
INSERT INTO 
    @Dname 
SELECT 
    CName2 
FROM 
    Doctors2 LIMIT 1;

If it is a variable you should assign:

declare @Dname nvarchar(100)
select 
    @Dname = Cname2
from
    Doctors2 LIMIT 1;

Pyrrho:

Thank you for your reply.

I have found a different way of getting values into local storage without using the Success Event, local storage. I have simply not been able to get it to work.

I will mark your answer as a solution but I am convinced that the Success Event, local storage is buggy and cannot be used safely.

Mike