我正在查找的表中有特定信息,此查询将显示它:
SELECT StringValue FROM ClientSettings
WHERE Setting like 'CompanyDomain'
OR Setting like 'CompanyActivityEmail'
OR Setting like 'CompanySupportPhone'
OR Setting like 'CompanyName'
它返回以下日期:
StringValue
MyCompanyName
MyCompanyName@email.com
www.mycompanydomain.com
801-555-1212
我现在尝试将这些设置为变量,而不必制作 4 个单独的选择语句。
这是我所拥有的,但它没有按我的意愿工作:
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
我很好奇我什至尝试的东西是否可能?