Showing posts with label master. Show all posts
Showing posts with label master. Show all posts

Monday, March 19, 2012

Last insert id

Hi

I am trying to import several master detail records from files to ms sql
server.
I have orders file and order_items file that has several rows for each
order.
If I insert programmatically these records how can find out which order ID
was the last inserted, so that I can attach the subsesquent row items to a
proper order.

I am quite new to ms sql server. I have used mysql a lot and there I could
use mysql_insert_id to find out the last autoincremented filed number.
I am looking for a similar method for ms sql server 2000.

TIA
George"George Hill" <ghill@.NOSPAM.com> wrote in message
news:LUf8b.5984$ZB4.5409@.reader1.news.jippii.net.. .
> Hi
> I am trying to import several master detail records from files to ms sql
> server.
> I have orders file and order_items file that has several rows for each
> order.
> If I insert programmatically these records how can find out which order ID
> was the last inserted, so that I can attach the subsesquent row items to a
> proper order.
> I am quite new to ms sql server. I have used mysql a lot and there I could
> use mysql_insert_id to find out the last autoincremented filed number.
> I am looking for a similar method for ms sql server 2000.
> TIA
> George

Assuming that you're using an IDENTITY column to generate the IDs, then the
scope_identity() function will give the last ID inserted. There are also
ident_current() and @.@.identity - see Books Online for an explanation - but
scope_identity() is probably the one you want.

Simon

Wednesday, March 7, 2012

Large System Databases

I manage a SQL Server where the master database is almost 3 times
larger than any other database and the tempdb is even bigger than that.
I have not been monitoring the size of these databases for very long
so I don't have a good baseline. However, it seems like a problem. I
would appreciate any help.
Thanks!
What is large? Does the app use master to store user data?
Andrew J. Kelly SQL MVP
"shanghai360" <scott.seely@.sfsoma.com> wrote in message
news:1143653999.425234.24030@.t31g2000cwb.googlegro ups.com...
>I manage a SQL Server where the master database is almost 3 times
> larger than any other database and the tempdb is even bigger than that.
> I have not been monitoring the size of these databases for very long
> so I don't have a good baseline. However, it seems like a problem. I
> would appreciate any help.
> Thanks!
>
|||The Master database is 3.6 GB and Tempdb is 4.5 GB...perhaps not so big
for some environments.
You are right, our Sitescope monitoring software maintains a log table
in the Master database that is 3.3 GB alone. Is that a good practice?
Thank you for your help Sir!
|||No that is very poor practice. Why would you use the Master database as a
user db? If that is third party software then you should ask for your money
back and tell them to call you when they get a clue. It is impossible to
say why tempdb is that big and if it is needed that big or not without much
more information. Check to be sure there are no long running open
transactions in Tempdb.
Andrew J. Kelly SQL MVP
"shanghai360" <scott.seely@.sfsoma.com> wrote in message
news:1143749039.920309.50530@.v46g2000cwv.googlegro ups.com...
> The Master database is 3.6 GB and Tempdb is 4.5 GB...perhaps not so big
> for some environments.
> You are right, our Sitescope monitoring software maintains a log table
> in the Master database that is 3.3 GB alone. Is that a good practice?
> Thank you for your help Sir!
>
|||It turned out that it was 3rd party software and consultant that
installed it in the Master. Thanks to your help we were able to
resolve the problem and move the table into a user database. We regard
to temp there was no long running open transactions...I restarted the
sql service and it shrunk to a resonable size, I'm monitoring it now.
Thanks again!

Friday, February 24, 2012

Large System Databases

I manage a SQL Server where the master database is almost 3 times
larger than any other database and the tempdb is even bigger than that.
I have not been monitoring the size of these databases for very long
so I don't have a good baseline. However, it seems like a problem. I
would appreciate any help.
Thanks!What is large? Does the app use master to store user data?
--
Andrew J. Kelly SQL MVP
"shanghai360" <scott.seely@.sfsoma.com> wrote in message
news:1143653999.425234.24030@.t31g2000cwb.googlegroups.com...
>I manage a SQL Server where the master database is almost 3 times
> larger than any other database and the tempdb is even bigger than that.
> I have not been monitoring the size of these databases for very long
> so I don't have a good baseline. However, it seems like a problem. I
> would appreciate any help.
> Thanks!
>|||The Master database is 3.6 GB and Tempdb is 4.5 GB...perhaps not so big
for some environments.
You are right, our Sitescope monitoring software maintains a log table
in the Master database that is 3.3 GB alone. Is that a good practice?
Thank you for your help Sir!|||No that is very poor practice. Why would you use the Master database as a
user db? If that is third party software then you should ask for your money
back and tell them to call you when they get a clue. It is impossible to
say why tempdb is that big and if it is needed that big or not without much
more information. Check to be sure there are no long running open
transactions in Tempdb.
--
Andrew J. Kelly SQL MVP
"shanghai360" <scott.seely@.sfsoma.com> wrote in message
news:1143749039.920309.50530@.v46g2000cwv.googlegroups.com...
> The Master database is 3.6 GB and Tempdb is 4.5 GB...perhaps not so big
> for some environments.
> You are right, our Sitescope monitoring software maintains a log table
> in the Master database that is 3.3 GB alone. Is that a good practice?
> Thank you for your help Sir!
>|||It turned out that it was 3rd party software and consultant that
installed it in the Master. Thanks to your help we were able to
resolve the problem and move the table into a user database. We regard
to temp there was no long running open transactions...I restarted the
sql service and it shrunk to a resonable size, I'm monitoring it now.
Thanks again!

Large System Databases

I manage a SQL Server where the master database is almost 3 times
larger than any other database and the tempdb is even bigger than that.
I have not been monitoring the size of these databases for very long
so I don't have a good baseline. However, it seems like a problem. I
would appreciate any help.
Thanks!What is large? Does the app use master to store user data?
Andrew J. Kelly SQL MVP
"shanghai360" <scott.seely@.sfsoma.com> wrote in message
news:1143653999.425234.24030@.t31g2000cwb.googlegroups.com...
>I manage a SQL Server where the master database is almost 3 times
> larger than any other database and the tempdb is even bigger than that.
> I have not been monitoring the size of these databases for very long
> so I don't have a good baseline. However, it seems like a problem. I
> would appreciate any help.
> Thanks!
>|||The Master database is 3.6 GB and Tempdb is 4.5 GB...perhaps not so big
for some environments.
You are right, our Sitescope monitoring software maintains a log table
in the Master database that is 3.3 GB alone. Is that a good practice?
Thank you for your help Sir!|||No that is very poor practice. Why would you use the Master database as a
user db? If that is third party software then you should ask for your money
back and tell them to call you when they get a clue. It is impossible to
say why tempdb is that big and if it is needed that big or not without much
more information. Check to be sure there are no long running open
transactions in Tempdb.
Andrew J. Kelly SQL MVP
"shanghai360" <scott.seely@.sfsoma.com> wrote in message
news:1143749039.920309.50530@.v46g2000cwv.googlegroups.com...
> The Master database is 3.6 GB and Tempdb is 4.5 GB...perhaps not so big
> for some environments.
> You are right, our Sitescope monitoring software maintains a log table
> in the Master database that is 3.3 GB alone. Is that a good practice?
> Thank you for your help Sir!
>|||It turned out that it was 3rd party software and consultant that
installed it in the Master. Thanks to your help we were able to
resolve the problem and move the table into a user database. We regard
to temp there was no long running open transactions...I restarted the
sql service and it shrunk to a resonable size, I'm monitoring it now.
Thanks again!