Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable Database clause
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00762773
Message ID:
00763328
Vues:
21
Why not put the stored procedure in each database?

-Mike

>The folowing select needs to run against 15 different databases (one for each region) on this server and 5 more on another server.
>
>
>SELECT db.id, db.location_id, cs.name, db.total_due, db.check_num, db.check_date, cs.ssn,
> RTRIM(ISNULL(cs.address_1,' ') + ' ' + ISNULL(cs.address_2,' ')) address, cs.city,
> cs.state_id, cs.zip, cs.primary_phone, cs.secondary_phone, bk.name, db.routing_id,
> db.account_num, '' AS ref_name, '' AS ref_addr, '' AS ref_phone, db.status
> FROM AZ_Reg..debt db
> INNER JOIN AZ_Reg..debthistory dh ON dh.debt_id = db.id
> INNER JOIN AZ_Reg..deferred df ON df.debt_id = db.id
> INNER JOIN AZ_Reg..customer cs ON df.customer_id = cs.id
> INNER JOIN AZ_Reg..bank bk ON db.routing_id = bk.routing_id
> WHERE db.status = 'cor'
> AND dh.date between @StartDate AND CAST(@EndDate AS datetime) + ' 23:59:59'
> AND dh.type = 'sta'
> AND dh.description = 'Changed To: COR'
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform