Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SP with multiple tables and databases (insert & delete)
Message
From
26/02/2003 13:40:54
 
 
To
26/02/2003 13:01:47
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00758108
Message ID:
00758310
Views:
18
This message has been marked as a message which has helped to the initial question of the thread.
You might have to start a distributed transaction since you're stretching the transaction across databases.

-Mike

>>>>Thanks a lot, this is a great starting point. I was my halfway of setting these tables up, but then switched to reading some forums, etc. :)
>>>
>>>Actually, I didn't even think. To change to the correct database you could do:
>>>
>>>
>>>IF @tcState = 'CT'
>>>   USE CTCredit
>>>
>>>IF @tcState = 'MA'
>>>   USE MACredit
>>>
>>>
>>>BOb
>>
>>Are you sure, I have to switch? Can I use full notation instead in my queries and use USE command.
>
>No, you don't have to switch, you could just use the full notation to...
>
>IF @tcState = 'CT'
>BEGIN
> UPDATE CTCredit.dbo.tablename SET .....
>END
>
>That would work too. You would just have to write the same SQL twice. A little more maintenance for your code. You can use the variable in the notation like this:
>
>UPDATE (@tcState+'Credit.dbo.tablename') like you could in foxpro. But, you could go this route, build the code into a string and then exec() it.
>
>BOb
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform