I have a database with 3 instants running. Depending on ths data in the first I need to continu running a scrip an the second or thered instant.
--
USE VTS_GEN_DATA
declare @sprVendorCode varchar(10),
@sprDBName varchar(20)
SET @sprVendorCode = '0000103374' --'0000103374' '0000100055'
SELECT @sprDBName = DBName FROM VTS_GEN_DATA.db o.DCSAVendor WHERE Code = @sprVendorCode
IF @sprDBName = 'VTS_COM_DATA'
BEGIN
USE VTS_COM_DATA
END
ELSE
BEGIN
USE VTS_SQL_DATA
END
SELECT top 10 CustAccNo FROM dbo.Customers
--
If I do this it will use the last USE
Is there any other way??
--
USE VTS_GEN_DATA
declare @sprVendorCode varchar(10),
@sprDBName varchar(20)
SET @sprVendorCode = '0000103374' --'0000103374' '0000100055'
SELECT @sprDBName = DBName FROM VTS_GEN_DATA.db o.DCSAVendor WHERE Code = @sprVendorCode
IF @sprDBName = 'VTS_COM_DATA'
BEGIN
USE VTS_COM_DATA
END
ELSE
BEGIN
USE VTS_SQL_DATA
END
SELECT top 10 CustAccNo FROM dbo.Customers
--
If I do this it will use the last USE
Is there any other way??