I have a specific information in a table I am looking for, this query will show it:
SELECT StringValue FROM ClientSettings
WHERE Setting like 'CompanyDomain'
OR Setting like 'CompanyActivityEmail'
OR Setting like 'CompanySupportPhone'
OR Setting like 'CompanyName'
It returns the following date:
StringValue
MyCompanyName
MyCompanyName@email.com
www.mycompanydomain.com
801-555-1212
I am trying to now set these up to variables without having to make 4 separate select statements.
Here is what I have, but it is not working as I want it to:
DECLARE @CompanyName VARCHAR(100)
DECLARE @CompanyDomain VARCHAR(100)
SELECT @CompanyName = StringValue, @CompanyDomain = StringValue FROM ClientSettings
WHERE Setting like 'CompanyName'
OR Setting like 'CompanyDomain'
SELECT @CompanyName
SELECT @CompanyDomain
I am curious if what I am even trying is possible?
I think the issue is that you should only assign one value for each row, but not overwrite the other variables at the same time. A
CASEstatement should let you do this: