Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Sunday, March 25, 2012

Difference between Dataadapter.update and openxml

what is the scenario proccessing in the bulk updation operation

dataadapter.update or by using open xml

which one is best

please guide me

If you tell me more about your scenario, I can try to give you a better recommendation.

If you are trying to get Xml into the SQL Server there are a few options:

1) openxml/xquery nodes() method. This has the most flexibility of the options. You can use xpath or xquery to specify the transformation from xml to relational. This helps you expose the XML as a table, and then you can iterate over it to get it into your existing tables. This is best suited for inserting moderate sized xml messages into the database.

2) dataset. This option has the least flexibility if you are trying to map from an existing xml structure to an existing relational structure, but it also requires the least configuration. In addition it can support applying updates as well as inserts using the dataset diffgram xml format.

3) SQLXML Bulkload: This requires that you author an XSD schema and annotated it with mappings to your database. It is optimized for streaming nested xml files in the GB range.

4) SQL Server Integration Services: SISS also supports XML sources in its transformation pipeline. This is optimized for large data transformation operations that require a number of data transformations along the way.

If you are already using the dataset then going this route is probably going to be the easiest. If you need lots of flexibility in your mapping, and your xml files are moderately sized, then nodes/openxml might be the way to go. If you are planning on uploading multi-GB files, then you should look into Bulkload or SSIS.

|||

I have the scenario of selecting values from more than one tables, also while updating the values to DB from Datagrid some changes may or may not be made in grod

Then check the values alreay existing table to the grid values now i had written in OPENXML inside a Stored procedure,the SP have if statements, INSERT,UPDATE for one table or more than one table

which one is best openxml or the adapter.update is best,

Also how can achieve more than one t-sql operation in adapter.update

the SP is below

/*

To UPDATE And INSERT the Asset Values and Asset Status, and to INSERT Asset Change History

For the Assets which are Value and Status Changed

*/

Create procedure AssetValueStatusAdjustment_InsertUpdate

@.XMLString text
,@.LastModifiedUserID varchar(10)
,@.LastModifiedDate varchar(10)
,@.CultureID varchar(5)
As
BEGIN
SET NOCOUNT ON
Declare @.InventoryHistoryID bigint
Declare @.handle int
Declare @.XMLStatusName nvarchar(50)
Declare @.TableStatusName nvarchar(50)
Declare @.Error int

EXEC sp_xml_preparedocument @.handle OUTPUT, @.XMLString

-- This is For INSERT the Details of the Value Adjustment Assets into the Table
-- Inventory_ValueAdjustment

INSERT INTO Inventory_ValueAdjustment
(InventoryID
,PostDate
,PreAdjustmentOriginalCost
,PreAdjustmentNetValue
,AdjustmentAmount
,Comment
,GLTemplateID
,LastModifiedUserID
,LastModifiedDate)

SELECT
XMLAdjustmentColumns.InventoryID
,XMLAdjustmentColumns.PostDate
,XMLAdjustmentColumns.PreAdjustmentOriginalCost
,XMLAdjustmentColumns.PreAdjustmentNetValue
,XMLAdjustmentColumns.AdjustmentAmount
,XMLAdjustmentColumns.Comment
,XMLAdjustmentColumns.GLTemplateID
,@.LastModifiedUserID as LastModifiedUserID
,@.LastModifiedDate as LastModifiedDate


From OPENXML(@.handle,'Root/Asset',1)

--This Fields From Inventory_ValueAdjustment Table

With(InventoryID bigint,
PostDate datetime,
PreAdjustmentOriginalCost decimal(18,2),
PreAdjustmentNetValue decimal(18,2),
AdjustmentAmount decimal(18,2),
Comment nvarchar(200),
GLTemplateID int)XMLAdjustmentColumns

SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch


-- UPDATE the ValueAdjustment to Inventory_Profile

UPDATE
Inventory_Profile
SET
NetValue=XMLAdjustmentColumns.NetValue
,LastModifiedUserID= @.LastModifiedUserID
,LastModifiedDate=@.LastModifiedDate


From OPENXML(@.handle,'Root/Asset',1)

--This Fields From Inventory_ValueAdjustment Table

With(InventoryID bigint,
NetValue decimal(19,2))XMLAdjustmentColumns

WHERE
Inventory_Profile.InventoryID=XMLAdjustmentColumns.InventoryID


SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch


--INSERT a ValueAdjustment Change History Record

INSERT INTO Inventory_History
(InventoryHistoryID
,InventoryID
,AsOfDate--
,ANum--
,LNum--
,HisoryGenerationReasonID
,Alias
,InventoryStatusID
,InventorySubStatusID
,InventorySubTypeID
,InventoryTypeID
,AcquisitionDate
,OriginalCost
,NetValue
,UnitNumber
,YearOfManufacture
,Manufacturer
,Make
,Model
,SerialNumber
,FundingSourceID--
,OwnerSinceDate--
,UsageConditionID
,Description1
,Description2
,InventoryLocationID
,LocationEffectiveFromDate
,IsFlaggedForSale
,IsDepreciationAllowed--
,PortfolioID
,RentalPurchaseOrderNumber
,AquisitionPurchaseOrderNumber
,CostCenterID
,OwnerTypeID
,IsReplacementUnitOnOrder
,CustomerBookValue
,GLTemplateID
,FlaggedForCofAAlias
,FlaggedForLeaseAlias
,CustomerID
,PreviousLeaseID
,SortOrder
,IsSaleLeaseBack
,ParentInventoryID
,Quantity
,OldSerialNumber
,InventoryGroupID
,InvoiceGroupID
,FactorCategoryID
,IsEligibleForPropertyTaxManagement
,InterimRentReceivableUpfrontTaxModeID
,LeaseRentalReceivableUpfrontTaxModeID
,OverTermReceivableUpfrontTaxModeID
,LastModifiedUserID
,LastModifiedDate)

SELECT
XMLAdjustmentColumns.InventoryHistoryID as InventoryHistoryID
,Inventory_Profile.InventoryID
,XMLAdjustmentColumns.AsOfDate as AsOfDate
,XMLAdjustmentColumns.ANum as ANum
,XMLAdjustmentColumns.LNum as LNum
,XMLAdjustmentColumns.HisoryGenerationReasonID as HisoryGenerationReasonID
,Inventory_Profile.Alias
,Inventory_Profile.InventoryStatusID
,Inventory_Profile.InventorySubStatusID
,Inventory_Profile.InventorySubTypeID
,Inventory_Profile.InventoryTypeID
,Inventory_Profile.AcquisitionDate
,Inventory_Profile.OriginalCost
,Inventory_Profile.NetValue
,Inventory_Profile.UnitNumber
,Inventory_Profile.YearOfManufacture
,Inventory_Profile.Manufacturer
,Inventory_Profile.Make
,Inventory_Profile.Model
,Inventory_Profile.SerialNumber
,XMLAdjustmentColumns.FundingSourceID as FundingSourceID
,XMLAdjustmentColumns.OwnerSinceDate as OwnerSinceDate
,Inventory_Profile.UsageConditionID
,Inventory_Profile.Description1
,Inventory_Profile.Description2
,Inventory_Profile.InventoryLocationID
,Inventory_Profile.LocationEffectiveFromDate
,Inventory_Profile.IsFlaggedForSale
,XMLAdjustmentColumns.IsDepreciationAllowed as IsDepreciationAllowed
,Inventory_Profile.PortfolioID
,Inventory_Profile.RentalPurchaseOrderNumber
,Inventory_Profile.AquisitionPurchaseOrderNumber
,Inventory_Profile.CostCenterID
,Inventory_Profile.OwnerTypeID
,Inventory_Profile.IsReplacementUnitOnOrder
,Inventory_Profile.CustomerBookValue
,Inventory_Profile.GLTemplateID
,Inventory_Profile.FlaggedForCofAAlias
,Inventory_Profile.FlaggedForLeaseAlias
,Inventory_Profile.CustomerID
,Inventory_Profile.PreviousLeaseID
,Inventory_Profile.SortOrder
,Inventory_Profile.IsSaleLeaseBack
,Inventory_Profile.ParentInventoryID
,Inventory_Profile.Quantity
,Inventory_Profile.OldSerialNumber
,Inventory_Profile.InventoryGroupID
,Inventory_Profile.InvoiceGroupID
,Inventory_Profile.FactorCategoryID
,Inventory_Profile.IsEligibleForPropertyTaxManagement
,Inventory_Profile.InterimRentReceivableUpfrontTaxModeID
,Inventory_Profile.LeaseRentalReceivableUpfrontTaxModeID
,Inventory_Profile.OverTermReceivableUpfrontTaxModeID
,@.LastModifiedUserID as LastModifiedUserID
,@.LastModifiedDate as LastModifiedDate

FROM
Inventory_Profile INNER JOIN OPENXML(@.handle,'Root/Asset',1)

--This Field From Inventory_ValueAdjustment Table

WITH(InventoryHistoryID bigint,
InventoryID bigint,
--This Fields From Inventory_History Table
AsOfDate datetime,
ANum nvarchar(50),
LNum int,
HisoryGenerationReasonID tinyint,
FundingSourceID int,
OwnerSinceDate datetime,
IsDepreciationAllowed tinyint) XMLAdjustmentColumns

ON
Inventory_Profile.InventoryID=XMLAdjustmentColumns.InventoryID


SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch


-- Check Wheather the Status has been Changed or not
SELECT
@.XMLStatusName = XMLAdjustmentColumns.InventoryStatusName
,@.TableStatusName = Inventory_Status_CnfgLocale.InventoryStatusName

FROM
Inventory_Status_Cnfg

INNER JOIN
Inventory_Status_CnfgLocale ON Inventory_Status_Cnfg.InventoryStatusID=Inventory_Status_CnfgLocale.InventoryStatusID

INNER JOIN
OPENXML(@.handle,'Root/Asset',1)

--This Fields From Inventory_Profile Table

WITH(InventoryStatusName nvarchar(100)
,InventoryStatusID tinyint
,CultureID varchar(5))XMLAdjustmentColumns

ON
Inventory_Status_CnfgLocale.InventoryStatusID=XMLAdjustmentColumns.InventoryStatusID

AND
Inventory_Status_CnfgLocale.CultureID=@.CultureID

SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch

-- If New Status is not matched with the existing Status Name then

IF(@.XMLStatusName <> @.TableStatusName)

BEGIN --To Insert Status Change Record

--UPDATE the New Status Changed Value to Inventory_Profile

UPDATE
Inventory_Profile
SET
InventoryStatusID = XMLAdjustmentColumns.InventoryStatusId
,LastModifiedUserID= @.LastModifiedUserID
,LastModifiedDate=@.LastModifiedDate

FROM
OPENXML(@.handle,'Root/Asset',1)

--This Fields From Inventory_Profile Tavle

WITH(InventoryStatusID tinyint
,InventoryID bigint)XMLAdjustmentColumns

WHERE
Inventory_Profile.InventoryID=XMLAdjustmentColumns.InventoryID


SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch


--Select the Maximum available InventoryHistoryID to avoid primary key violation
SELECT
@.InventoryHistoryID=COUNT(InventoryHistoryID)
FROM
Inventory_History

SET @.InventoryHistoryID = @.InventoryHistoryID+1

SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch


-- INSERT a status change history record

INSERT INTO Inventory_History
(InventoryHistoryID
,InventoryID
,AsOfDate--
,ANum--
,LNum--
,HisoryGenerationReasonID
,Alias
,InventoryStatusID
,InventorySubStatusID
,InventorySubTypeID
,InventoryTypeID
,AcquisitionDate
,OriginalCost
,NetValue
,UnitNumber
,YearOfManufacture
,Manufacturer
,Make
,Model
,SerialNumber
,FundingSourceID--
,OwnerSinceDate--
,UsageConditionID
,Description1
,Description2
,InventoryLocationID
,LocationEffectiveFromDate
,IsFlaggedForSale
,IsDepreciationAllowed--
,PortfolioID
,RentalPurchaseOrderNumber
,AquisitionPurchaseOrderNumber
,CostCenterID
,OwnerTypeID
,IsReplacementUnitOnOrder
,CustomerBookValue
,GLTemplateID
,FlaggedForCofAAlias
,FlaggedForLeaseAlias
,CustomerID
,PreviousLeaseID
,SortOrder
,IsSaleLeaseBack
,ParentInventoryID
,Quantity
,OldSerialNumber
,InventoryGroupID
,InvoiceGroupID
,FactorCategoryID
,IsEligibleForPropertyTaxManagement
,InterimRentReceivableUpfrontTaxModeID
,LeaseRentalReceivableUpfrontTaxModeID
,OverTermReceivableUpfrontTaxModeID
,LastModifiedUserID
,LastModifiedDate)

SELECT
@.InventoryHistoryID as InventoryHistoryID
,Inventory_Profile.InventoryID
,XMLAdjustmentColumns.AsOfDate as AsOfDate
,XMLAdjustmentColumns.ANum as ANum
,XMLAdjustmentColumns.LNum as LNum
,XMLAdjustmentColumns.HisoryGenerationReasonID as HisoryGenerationReasonID
,Inventory_Profile.Alias
,Inventory_Profile.InventoryStatusID
,Inventory_Profile.InventorySubStatusID
,Inventory_Profile.InventorySubTypeID
,Inventory_Profile.InventoryTypeID
,Inventory_Profile.AcquisitionDate
,Inventory_Profile.OriginalCost
,Inventory_Profile.NetValue
,Inventory_Profile.UnitNumber
,Inventory_Profile.YearOfManufacture
,Inventory_Profile.Manufacturer
,Inventory_Profile.Make
,Inventory_Profile.Model
,Inventory_Profile.SerialNumber
,XMLAdjustmentColumns.FundingSourceID as FundingSourceID
,XMLAdjustmentColumns.OwnerSinceDate as OwnerSinceDate
,Inventory_Profile.UsageConditionID
,Inventory_Profile.Description1
,Inventory_Profile.Description2
,Inventory_Profile.InventoryLocationID
,Inventory_Profile.LocationEffectiveFromDate
,Inventory_Profile.IsFlaggedForSale
,XMLAdjustmentColumns.IsDepreciationAllowed as IsDepreciationAllowed
,Inventory_Profile.PortfolioID
,Inventory_Profile.RentalPurchaseOrderNumber
,Inventory_Profile.AquisitionPurchaseOrderNumber
,Inventory_Profile.CostCenterID
,Inventory_Profile.OwnerTypeID
,Inventory_Profile.IsReplacementUnitOnOrder
,Inventory_Profile.CustomerBookValue
,Inventory_Profile.GLTemplateID
,Inventory_Profile.FlaggedForCofAAlias
,Inventory_Profile.FlaggedForLeaseAlias
,Inventory_Profile.CustomerID
,Inventory_Profile.PreviousLeaseID
,Inventory_Profile.SortOrder
,Inventory_Profile.IsSaleLeaseBack
,Inventory_Profile.ParentInventoryID
,Inventory_Profile.Quantity
,Inventory_Profile.OldSerialNumber
,Inventory_Profile.InventoryGroupID
,Inventory_Profile.InvoiceGroupID
,Inventory_Profile.FactorCategoryID
,Inventory_Profile.IsEligibleForPropertyTaxManagement
,Inventory_Profile.InterimRentReceivableUpfrontTaxModeID
,Inventory_Profile.LeaseRentalReceivableUpfrontTaxModeID
,Inventory_Profile.OverTermReceivableUpfrontTaxModeID
,@.LastModifiedUserID as LastModifiedUserID
,@.LastModifiedDate as LastModifiedDate

FROM
Inventory_Profile INNER JOIN OPENXML(@.handle,'Root/Asset',1)

--This Field From Inventory_ValueAdjustment Table

WITH(InventoryHistoryID bigint,
InventoryID bigint,
--This Fields From Inventory_History Table

AsOfDate datetime,
ANum nvarchar(50),
LNum int,
HisoryGenerationReasonID tinyint,
FundingSourceID int,
OwnerSinceDate datetime,
IsDepreciationAllowed tinyint) XMLAdjustmentColumns

ON
Inventory_Profile.InventoryID=XMLAdjustmentColumns.InventoryID

SET @.Error=@.@.Error
IF(@.Error<>0)
GOTO ErrorCatch


END

GOTO NextStatement --dont want to Update the Status GOTO Next expression


NextStatement:


ErrorCatch:
RETURN @.Error


EXEC sp_xml_removedocument @.handle
END
Go

/*

This Stored Procedure Will Insert two tables as Inventory_Profile, Inventory_History and

Update TaxDepreciation_Profile by OPENXML BULK UPDATE CONCEPT

-
The @.xmlString Parameter is used to get the value as XML Nodes From the Non Transaction

Class

-

*/

guideme please

Monday, March 19, 2012

Diakrieten worden niet opgeslagen

Hi,
When I use the update statement "UPDATE tablename SET field =3D
'As=FBca' WHERE fieldid =3D 1" will generate in the field "Asuca". How
is that possible?
When I cut and paste the field within Enterprise Manager the field
looks like "As=FBca".
So... whats the problem?
Thanks,
Ron
Diver
Try
UPDATE tablename SET field =N'Asca' WHERE fieldid = 1
"Diver" <rnooit@.hotmail.com> wrote in message
news:1121756360.293341.217730@.g47g2000cwa.googlegr oups.com...
Hi,
When I use the update statement "UPDATE tablename SET field =
'Asca' WHERE fieldid = 1" will generate in the field "Asuca". How
is that possible?
When I cut and paste the field within Enterprise Manager the field
looks like "Asca".
So... whats the problem?
Thanks,
Ron
|||Uri,
Thanks. But is there any sqlserver setting that i can set for the whole
database?
Ron

Diakrieten worden niet opgeslagen

Hi,
When I use the update statement "UPDATE tablename SET field =3D
'As=FBca' WHERE fieldid =3D 1" will generate in the field "Asuca". How
is that possible?
When I cut and paste the field within Enterprise Manager the field
looks like "As=FBca".
So... whats the problem?
Thanks,
RonDiver
Try
UPDATE tablename SET field =N'Asca' WHERE fieldid = 1
"Diver" <rnooit@.hotmail.com> wrote in message
news:1121756360.293341.217730@.g47g2000cwa.googlegroups.com...
Hi,
When I use the update statement "UPDATE tablename SET field =
'Asca' WHERE fieldid = 1" will generate in the field "Asuca". How
is that possible?
When I cut and paste the field within Enterprise Manager the field
looks like "Asca".
So... whats the problem?
Thanks,
Ron|||Uri,
Thanks. But is there any sqlserver setting that i can set for the whole
database?
Ron

Diakrieten worden niet opgeslagen

Hi,
When I use the update statement "UPDATE tablename SET field =3D
'As=FBca' WHERE fieldid =3D 1" will generate in the field "Asuca". How
is that possible?
When I cut and paste the field within Enterprise Manager the field
looks like "As=FBca".
So... whats the problem?
Thanks,
RonDiver
Try
UPDATE tablename SET field =N'Asûca' WHERE fieldid = 1
"Diver" <rnooit@.hotmail.com> wrote in message
news:1121756360.293341.217730@.g47g2000cwa.googlegroups.com...
Hi,
When I use the update statement "UPDATE tablename SET field ='Asûca' WHERE fieldid = 1" will generate in the field "Asuca". How
is that possible?
When I cut and paste the field within Enterprise Manager the field
looks like "Asûca".
So... whats the problem?
Thanks,
Ron|||Uri,
Thanks. But is there any sqlserver setting that i can set for the whole
database?
Ron

Wednesday, March 7, 2012

Development Direction

I'm hoping that someone can suggest a direction for me to get started to
update a current application that I built several years ago. I want to move
the following application to our organization's intranet and will need to get
training in the best method to achieve this. I am versed in Office VBA and
VB 6.0 but have not moved into the .NET arena yet.
The application in question uses SQL Server 2000 as a back end and Access
2000 for the front end. Users basically select options on an Access form
that is used in a pass-through query to SQL Server. The query logs into the
server runs the query and returns the data, not to Access, but to an Excel
spreadsheet. I did this at the request of the users and they have been very
happy with it for many years.
The problem lies when users get new machines or have their machines
re-imaged and our computer support group has to re-install yet another
application. It would be great if I could figure out a way to build a
web-enabled version of this application and it has been beyond the scope of
my knowledge for some time now. I would really appreciate any suggestions
you might have or if you feel I need to direct this question to a different
newsgroup. Please advise. Thank you... AlIf you are able to use Reporting Services this is pretty easy to do what you
want. You have the queries designed. They can use the portal that ships with
RS (Report Manager). Select the parameters and view the report and then
export to Excel. If you had your own web page you could go directly to Excel
but since you don't want to be creating your own web app my suggestion
totally uses the feature of RS. You design and deploy the report and there
you are BUT the problem is going to be the administration. It requires
having RS server somewhere that you can deploy against.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Al" <Al@.discussions.microsoft.com> wrote in message
news:FD312550-1020-4D2B-B913-AE40BB5A28BC@.microsoft.com...
> I'm hoping that someone can suggest a direction for me to get started to
> update a current application that I built several years ago. I want to
> move
> the following application to our organization's intranet and will need to
> get
> training in the best method to achieve this. I am versed in Office VBA
> and
> VB 6.0 but have not moved into the .NET arena yet.
> The application in question uses SQL Server 2000 as a back end and Access
> 2000 for the front end. Users basically select options on an Access form
> that is used in a pass-through query to SQL Server. The query logs into
> the
> server runs the query and returns the data, not to Access, but to an Excel
> spreadsheet. I did this at the request of the users and they have been
> very
> happy with it for many years.
> The problem lies when users get new machines or have their machines
> re-imaged and our computer support group has to re-install yet another
> application. It would be great if I could figure out a way to build a
> web-enabled version of this application and it has been beyond the scope
> of
> my knowledge for some time now. I would really appreciate any suggestions
> you might have or if you feel I need to direct this question to a
> different
> newsgroup. Please advise. Thank you... Al

Tuesday, February 14, 2012

Determining the OS Version that SQL is running on

I am writing a client application that offers an UI that allows an administrator to remotely add/delete/update user accounts accross many different SQL Servers running on XP and up.

When the operating system is W2K3 or higher I want to take advantage of the "check_expiration, check_policy, must_change' arguments to create login and exclude those features when the host OS does not support them.

Is there an easy way to determine if those arguments are supported?

Thanks

Mark

The OS version information is returned with @.@.VERSION. You will have to parse it a bit to find the Version, Edition, and Build -but it's all there.|||

or you can try this .. in sql server 2005 you have some limitation with XP_Cmdshell ... it may not be enabled by default...

EXEC master..xp_cmdshell 'netsh diag SHOW os /p'

for more details refer this link : http://www.sqlmag.com/Article/ArticleID/46062/sql_server_46062.html

Madhu

|||

Also exec xp_msver will return the OS version (I think it is line 15 in the result set)

hth,

-Steven Gott

S/DET

SQL Server

|||

exec xp_msver is exactly what I am looking for

Thanks!