日期:2014-05-17 浏览次数:20894 次
ALTER PROCEDURE [dbo].[AddData](@QQNumber bigint,@QQPassword varchar(1000),@BeiZhu varchar(1000)=null)
AS
BEGIN
declare @tableNumber varchar(10);
declare @sql nvarchar(2000);
declare @count bigint;
declare @countsql nvarchar(2000);
set @tableNumber=Substring(CONVERT(varchar(20),@QQNumber),1,5);
set @countsql='select @count=count(QQNumber) from tab_'+@tableNumber+' where QQNumber='+Convert(varchar(20),@QQNumber);
exec sp_executesql @countsql,N'@count int output',@count output;
print @count;
begin Transaction;
if(@count<>0)
begin
set @QQPassword='∝'+@QQPassword;
set @sql='update tab_'+@tableNumber+' set QQPassword=QQPassword+'''+@QQPassword+'''where QQNumber='+Convert(varchar(20),@QQNumber);
exec(@sql);
end
else
begin
set @sql='insert into tab_'+@tableNumber+' (QQNumber,QQPassword,BeiZhu) values('''+Convert(varchar(20),@QQNumber)+''','''+@QQPassword+''','''+isnull(@BeiZhu,'NULL')+''')';
exec(@sql);
end
if(@@ERROR<>0)
begin
rollback Transaction;
return 0;
end
else
begin
commit Transaction;
return 1;
end
END
for (int i = 0; i < newdatas.Length; i++)
{
string[] tempstr = newdatas[i].Replace("----", "∽").Split('∽');
sql += "exec AddData @QQNumber=" + tempstr[0] + ",@QQPassword='" + tempstr[1].Replace("'", "") + "',@BeiZhu=null ";
if (i % 500 == 0)
{
ds.AddData(sql);
sql = string.Empty;
}
&nbs