Created
September 21, 2012 12:41
-
-
Save DavidSSL/3761248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[ufn_MimicView] | |
( | |
) | |
RETURNS | |
@ViewsData TABLE | |
( | |
A NVARCHAR(255) | |
, B NVARCHAR(255) | |
, C VARCHAR(255) | |
, D VARCHAR(255) | |
, E CHAR(50) | |
) | |
AS | |
BEGIN | |
-- Perform logic to see whether to call Database X or Y | |
IF(DatabaseToUse = 'X') | |
BEGIN | |
INSERT INTO | |
@ViewsData | |
SELECT | |
* | |
FROM | |
X | |
END | |
ELSE | |
BEGIN | |
INSERT INTO | |
@ViewsData | |
SELECT | |
* | |
FROM | |
Y | |
END | |
RETURN | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment