Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Not even sure whether it is possible

Author  Topic 

Mickybee
Starting Member

29 Posts

Posted - 2009-01-30 : 16:15:24
Hi all,
Im not a db expert but dabble.
We have two databases, one called DOCUMENT_MAN and the other called FINANCE.

The DOCUMENT_MAN database stores the location to all our documents.

I am trying to work out whether it is possible to (from FINANCE) to either create a view to the DOCUMENT_MAN database OR create a trigger which can update it.

Are either of these possible.

Many thanks,
Mike

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-30 : 16:16:48
A trigger wouldn't help, but yes you can create a view. Or you could just use a regular query. You just need to use the three-part naming convention for the object(s) in the other database.

--CREATE VIEW ...
SELECT ...
FROM DOCUMENT_MAN..SomeTable
...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Mickybee
Starting Member

29 Posts

Posted - 2009-01-30 : 16:23:00
Many thanks Tara, I had no idea you could do that. I will have a play.

thanks for your quick reply

Mike
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-30 : 16:24:32
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-31 : 08:06:21
quote:
Originally posted by Mickybee

Hi all,
Im not a db expert but dabble.
We have two databases, one called DOCUMENT_MAN and the other called FINANCE.

The DOCUMENT_MAN database stores the location to all our documents.

I am trying to work out whether it is possible to (from FINANCE) to either create a view to the DOCUMENT_MAN database OR create a trigger which can update it.

Are either of these possible.

Many thanks,
Mike


what update do you want to perform on DOCUMENT_MAN? perhaps what you need is to schedule a job in sql agent to call ssis package which does the data transfer to DOCUMENT_MAN to perform reqd operations.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-31 : 11:44:31
That seems like a lot of unnecessary steps for something that can be accomplished with simple T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Mickybee
Starting Member

29 Posts

Posted - 2009-01-31 : 12:16:33
Once we create a record on one of the finance tables, we will generate an incoice on the Document database.

I now have a view so I san see whether an invoice already exists.

I finally need to be able to insert a record into the Document database automatically when inserting into the Finance database.

Hopefully I can work this out, though I was hoping I could do it with a simple trigger
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-31 : 13:32:36
Are they in different server? then you could set up transactional replication between them to get finance data to document database and then apply the necessary logic to generate the invoice.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-31 : 18:10:15
For the insert portion, you can use a trigger. I said you couldn't earlier as I thought you were wanting to use a SELECT statement, which can't be triggered.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Mickybee
Starting Member

29 Posts

Posted - 2009-02-01 : 03:42:20
Hi all,

Many thanks for you help. Both databases are on the server.

I am happy to report that the Insert trigger works fine

Thanks again,
Mike
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-01 : 11:38:59
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -