i****a 发帖数: 36252 | 1 Do you see any problem with set rowcount?
BOL says:
Important:
Using SET ROWCOUNT will not affect DELETE, INSERT, and UPDATE statements in
the next release of SQL Server. Avoid using SET ROWCOUNT with DELETE, INSERT
, and UPDATE statements in new development work, and plan to modify
applications that currently use it. We recommend that DELETE, INSERT, and
UPDATE statements that currently are using SET ROWCOUNT be rewritten to use
TOP.
As I understand it should be ok because the select statemen... 阅读全帖 |
|
H********g 发帖数: 43926 | 2 小程序2,csv转换xls
#csv2xls.pl
use strict;
use warnings;
use Text::CSV;
use Spreadsheet::WriteExcel;
my @rows;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, "<:encoding(utf8)", "test.csv" or die "test.csv: $!";
my $rowcount=0;
while ( my $row_temp = $csv->getline( $fh ) ) {
push @rows, $row_temp;
print join "\t", @$row_temp,"\n";
$rowcount++;
}
$csv->eof or $csv->error_diag(... 阅读全帖 |
|
H********g 发帖数: 43926 | 3 升级版,可以读取命令行输入了
#csv2xls.pl
#>csv2xls.pl abcd.csv
#generages abcd.xls
use strict;
use warnings;
use Text::CSV;
use Spreadsheet::WriteExcel;
my $infile="test.csv" ;
if($ARGV[0]){$infile=$ARGV[0];}
my $basename=$infile;
$basename=~s/.csv//i;
my $outfile="$basename.xls";
my @rows;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, "<:encoding(utf8)", $infile or die "$infile: $!";
my $rowcount=... 阅读全帖 |
|
d*r 发帖数: 238 | 4 I found a way to do that in Table but not works with Matrix.
That is use iif(RowCount()).
The strange thing is that I can RowCount a table but cannot RowCount a matrix.
Researching ...... |
|
k*********g 发帖数: 791 | 5 1 功能
c++什么都能做,早期fortran只能做数值计算,现在能做非数值的东西,但还是远没有
c++完备;
其实,fortran77是个好东西:专项、简单;从fortran90开始,哲学出了问题;
2 软件开发
c++是开发软件的最好语言,很大程度是因为它的“面向对象”的特点,其实就是“鼓
励”、“帮助”庞大的程序群的“创造”、“管理”;
用fortran写软件,不仅仅有些功能(如,对计算机软硬件的操作)没法办,而且整个
软件会被管理得一塌糊涂;用c++,10个人1年就能搞定的东西,if用frotran,同样10
个人估计需要5年;
3 软件工程
即便不是做软件,而是写个1万行数量级的程序,c++也因为promotes优良的编程习惯而
战胜fortran;
4 super c
如果没有那么多的“object”,不需要++,那么可以不用c++的那些oop东西,把它当作
一个改进的c,有人称之super c,来用;这样,c++和fortran都是command oriented的
结构化语言; 用super c 写的程序,将来能比较迅速地upgrade成软件,if fortran,
得... 阅读全帖 |
|
j****s 发帖数: 34 | 6 I want to know how many records existing in the database.
In sql, it is
select count(*) from customer;
But I do not know how to get it in stored procedure.
CREATE proc countcustom @num Int output
as
select count(*) from user1
select @num = @@ROWCOUNT
return
GO
But num is always 1, since I do not know the meaning of @@ROWCOUNT, ( I copy
from other examples, :-()
I wonder somebody can help me, also is there any document or tutorai for
stored procedure? I do not quite understand the grammar o |
|
j*****n 发帖数: 1781 | 7 have a temp table to capture the result if ur dynamic SQL returns data set.
eg.
CREATE TABLE #result
(rowCount int)
DECLARE @sql varchar(max)
SET @sql = 'select count(1) from tbl'
INSERT INTO #result
EXEC(@sql)
use @@rowcount if @sql stores a DML |
|
b**********5 发帖数: 7881 | 8 小姐啊, mapreduce的input哪里来?
是hdfs file么? 一般来说, keyvalue是一个个进到你的system里来。 比如你的
sytem前面有个webservice, 然后client可以call你的service, 给你keyvalue, 你
直接写到HDFSfile里? 一般都是写到database里, 然后高兴怎么算就怎么算。
HBase的rowcount本来就是个mapreduce function
nn |
|
e*e 发帖数: 10 | 9 已经知道啦, 先set ROWCOUNT=1, 再reset回来. |
|
e*****g 发帖数: 20 | 10 我一直用如下的语句来得到查询的某一页
rst.PageSize = pagesize;
rst.AbsolutePage = pageno;
然后用
while( (!rst.Eof) && (rowcount < rst.PageSize) ) {
...
rst.MoveNext();
}
来访问改页内的每一条记录。
现在的问题是:如果还有另外一个查询需要同时参加排页怎么办?
最简单的情况,比如有目录和文件进行排页,要求目录在前,
在查询文件的时候,应该怎么处理啊?
当然两个查询的fields各不相同,能放在同一查询里面吗?
还是有什么别的办法处理?
请教各位大侠,谢谢。 |
|
a9 发帖数: 21638 | 11 begin transaction
select top 1 * from tablea with(tablock,xlock) where a.id=12
if @@rowcount=0 then
insert into tablea (id,status) values(12,0)
end if
commit transaction |
|
o****e 发帖数: 916 | 12 有一个很奇怪的数据库问题,还望高手相助。
数据库运行在web 服务器上,有一个stored procedure用来在user table生成新条目。
user table结构也很简单,主要的两个field是id和name,ID是一个identity field,
数据库自动生成的int。name是字符串,unique
stored procedure 如下:
=====================================
ALTER PROCEDURE [dbo].[AddUser]
@Name nvarchar(50),
@ID int out
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into Customer... 阅读全帖 |
|
g***l 发帖数: 18555 | 13 既然NAME是UNIQUE,为什么要set rowcount 1呢,IDENTITY可能也会有问题 |
|
j*******7 发帖数: 6300 | 14 还有“set rowcount 1“ 一般是根本不会用的.会有奇怪的副作用。 |
|
B*****g 发帖数: 34098 | 15 Cannot check I/O now.
update col = col, SQL%ROWCOUNT in oracle is not 0
and those records are locked if no commit. |
|
B*****g 发帖数: 34098 | 16 then use rowcount, hehe |
|
b**a 发帖数: 1118 | 17 I am using sth like this now:
DECLARE @count2 int
SET @count2 = 10000
WHILE @count2 >= 10000
BEGIN
DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
temp OPTION (MAXDOP 1)
SELECT @count2 = @@ROWCOUNT
END
and i really need it to run faster... |
|
y****w 发帖数: 3747 | 18 随手的脚本写法,保证能删光,又不想费事儿去搞到精确的批次,要不加个@@rowcount
=0跳出来也就行了。 |
|
b**a 发帖数: 1118 | 19 I am using sth like this now:
DECLARE @count2 int
SET @count2 = 10000
WHILE @count2 >= 10000
BEGIN
DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
temp OPTION (MAXDOP 1)
SELECT @count2 = @@ROWCOUNT
END
and i really need it to run faster... |
|
y****w 发帖数: 3747 | 20 随手的脚本写法,保证能删光,又不想费事儿去搞到精确的批次,要不加个@@rowcount
=0跳出来也就行了。 |
|
d**********3 发帖数: 1186 | 21 set rowcount =200
Loop begin
update ..
where PK between
loop end |
|
st 发帖数: 1685 | 22 of course, try that in your sql analyzer first,
select count(*) from user1 will return a number for the count(*)
that's one row, so you will get @num=@@ROWCOUNT, which is 1, :D |
|
a*f 发帖数: 1790 | 23 来自主题: Programming版 - 发个面试题 Order不用都装到内存里面
--total of a customer' orders
在ordersRepository里面定义个接口取这个数值,在ordersRepositoryImpl里面根据关
系或非关系或者in memory数据库实现,统计结果可能就一个SQL或者一个RowCounter
call就得到了,设计整个系统的时候应该不必care这个细节
--total of some customer at a state(eg. CA)
在customerRepository定义这个方法接口,在customerRepositoryImpl里面实现
--今后可能还要添加很多类似的东西,比如所有女性的购买金额
在ordersRepository添加一个接口,在ordersRepositoryImpl里面实现,orderService
添加接口,orderServiceImpl添加对应的call,其他程序代码不需要改动,系统结构依
然保持完美 |
|