我有一个简单的表格如下
CREATE TABLE [accounting].[ExtractControl](
[SourceSchema] [varchar](50) NOT NULL,
[SourceTable] [varchar](150) NOT NULL,
[SourceDatabase] [varchar](50) NOT NULL)
我想使用SourceSchema和SourceTable值选择SourceDatabase
目前我正在处理多个查询,如下所示
Select @s1 = SourceDatabase from accounting.ExtractControl where SourceSchema = 'xxx' and SourceTable = 'xxx'
Select @s2 = SourceDatabase from accounting.ExtractControl where SourceSchema = 'yyy' and SourceTable = 'yyy'
Select @s3 = SourceDatabase from accounting.ExtractControl where SourceSchema = 'xxx' and SourceTable = 'yyy'
我相信这可以以更优雅的方式完成!谢谢您的帮助!