Showing posts with label operation. Show all posts
Showing posts with label operation. Show all posts

Tuesday, March 27, 2012

Create a UNC Share

hi all,

i'm trying to write a script just like "copy database wizard" operation, for detaching, copy and ataching a database from a remote sql server to a local server.

Now the problem is when i try to copy the mdf file from the sql remote server to my local server.

Is it possible to create a UNC share in the remote sql server and delete after with t-sql like the Copy Database wizard does?

hope i made my self clear enought.

regards

Things like this should be planned and not ad-hoc. Though it's possible...

Code Snippet

exec xp_cmdshell 'net share sharename=<drive path>'

Tuesday, March 20, 2012

Create a column in RecordSet with the Record Count...

Hello

I'm reading a XML file and the next operation need a column with the row count.

I don't want to know how many rows there is in the recordset, but, the row count of each record.

How can I implement this?

tkx in advance
Paulo Aboim Pinto
Odivelas - Portugal

That issue was discussed here:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1074253&SiteID=1

Friday, February 17, 2012

counting records

Hi,
I need to count records in a table to make server-side paging. COUNT(ID) is
rather expensive operation. Can I relay on a query returning number of rows
for a table based on rowcnt field in sysindexes table? I mean if this query
will return up-to-date number of rows.
thanks
PrzemoYou can rely on rowcnt in sysindexes to return a number that was accurate at
some point, but not necessarily at the time you query it.
Two things you can do:
1. Don't use COUNT(field_name), use COUNT(*) - using * allows sql server to
choose the smallest index to count
2. Use the NOLOCK hint on the table(s) being queried; while your query could
be inaccurate due to using NOLOCK, it's probably worth the performance
benefit in this case
"Przemo" wrote:

> Hi,
> I need to count records in a table to make server-side paging. COUNT(ID) i
s
> rather expensive operation. Can I relay on a query returning number of row
s
> for a table based on rowcnt field in sysindexes table? I mean if this quer
y
> will return up-to-date number of rows.
> thanks
> Przemo|||If you run DBCC UPDATEUSAGE before the query.
HTH
Jerry
"Przemo" <Przemo@.discussions.microsoft.com> wrote in message
news:198952B1-B05A-4AAA-B1EE-E926DB23932A@.microsoft.com...
> Hi,
> I need to count records in a table to make server-side paging. COUNT(ID)
> is
> rather expensive operation. Can I relay on a query returning number of
> rows
> for a table based on rowcnt field in sysindexes table? I mean if this
> query
> will return up-to-date number of rows.
> thanks
> Przemo|||>> Can I relay on a query returning number of rows for a table based on
No, you cannot rely on the values in sysindexes. There are several known
instances where these values can be suspect. In some cases updating the
table statistics might help, but that is no way a guarantee for accuracy.
Anith|||When paging, is it really necessary to know beforehand how many total rows
are in the table or subset?
For example, would the following work?
select top 20 name, address, phone from customer where CustomerID >
@.PrevCustomerID
"Przemo" <Przemo@.discussions.microsoft.com> wrote in message
news:198952B1-B05A-4AAA-B1EE-E926DB23932A@.microsoft.com...
> Hi,
> I need to count records in a table to make server-side paging. COUNT(ID)
> is
> rather expensive operation. Can I relay on a query returning number of
> rows
> for a table based on rowcnt field in sysindexes table? I mean if this
> query
> will return up-to-date number of rows.
> thanks
> Przemo|||> select top 20 name, address, phone from customer
> where CustomerID > @.PrevCustomerID
You would need to ORDER BY CustomerID on that query.
"JT" wrote:

> When paging, is it really necessary to know beforehand how many total rows
> are in the table or subset?
> For example, would the following work?
> select top 20 name, address, phone from customer where CustomerID >
> @.PrevCustomerID
>
> "Przemo" <Przemo@.discussions.microsoft.com> wrote in message
> news:198952B1-B05A-4AAA-B1EE-E926DB23932A@.microsoft.com...
>
>|||I knew that, but it's a Friday afternoon, and I'm conserving keystrokes.
;-)
"KH" <KH@.discussions.microsoft.com> wrote in message
news:D8EFDC52-4244-41AE-9078-2945ED2B74A3@.microsoft.com...
> You would need to ORDER BY CustomerID on that query.
>
> "JT" wrote:
>