|
hi
Can anyone resolve my problem> I create a temp table and inserts data into it through Xml String
, spliting it by the character '|' . The data is inserted into the table fine but for last row it inserts only a part of it and does not inserts (" Remarks=""></item>|) of the xml string.
Can anyo please help or modify...the input xml string will be as given below.
{TO KNOW THE PROBLEM PRACTICALLY COPY THIS CODE IN NEW QUERY EDITOR AND EXECUTE}
--Declaring a temporary @TempTable
declare @TempTable table
(
AutoId int identity,
items varchar(max)
)
--Decaring a Variable
Declare @ExcelDataInXml varchar(max)
Set @ExcelDataInXml='<item TimeStamp="7/22/2006 12:00:00 AM" BlockName="s1" JobcodeId="80" UserInitial="amar" Error1="24" Error2="12" Error3="1" Error4="1" Error5="1" Error6="1" Error7="" Error8="1" Error9="" Error10="1" Remarks=" This is Test Data"></item>|<item TimeStamp="7/23/2006 12:00:00 AM" BlockName="s2" JobcodeId="80" UserInitial="amar" Error1="23" Error2="6" Error3="7" Error4="8" Error5="" Error6="7" Error7="" Error8="" Error9="" Error10="" Remarks="Second remark"></item>|<item TimeStamp="7/23/2006 12:00:00 AM" BlockName="s3" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="8" Error4="8" Error5="1" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s4" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="9" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s5" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="10" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s6" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="11" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s7" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="12" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s8" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="13" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s9" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="14" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="7/22/2006 12:00:00 AM" BlockName="s10" JobcodeId="80" UserInitial="amar" Error1="24" Error2="12" Error3="1" Error4="1" Error5="1" Error6="1" Error7="" Error8="1" Error9="" Error10="1" Remarks=" This is Test Data"></item>|<item TimeStamp="7/23/2006 12:00:00 AM" BlockName="s11" JobcodeId="80" UserInitial="amar" Error1="23" Error2="6" Error3="7" Error4="8" Error5="" Error6="7" Error7="" Error8="" Error9="" Error10="" Remarks="Second remark"></item>|<item TimeStamp="7/23/2006 12:00:00 AM" BlockName="s12" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="8" Error4="8" Error5="1" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s13" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="9" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s14" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="10" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s15" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="11" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s16" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="12" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2006 12:00:00 AM" BlockName="s17" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="13" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|<item TimeStamp="9/1/2007 12:00:00 AM" BlockName="sandeep" JobcodeId="80" UserInitial="amar" Error1="25" Error2="12" Error3="13" Error4="8" Error5="8" Error6="9" Error7="" Error8="1" Error9="1" Error10="1" Remarks=""></item>|'
--insert into TempTable
insert into @TempTable select * from SPLIT(@ExcelDataInXml,'|')
select * from @TempTable
thanx
sandeep
|
|
|
|
|
sandeep kumar pundhir wrote: insert into @TempTable select * from SPLIT(@ExcelDataInXml,'|')
I assume that SPLIT() is a UDF?
What does that function look like?
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Yes SPLIT is a User Defined Function
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION [dbo].[Split](@String nvarchar(4000), @Delimiter char(1))
RETURNS @Results TABLE (Items nvarchar(4000))
AS
BEGIN
DECLARE @INDEX INT
DECLARE @SLICE nvarchar(4000)
-- HAVE TO SET TO 1 SO IT DOESNT EQUAL Z
-- ERO FIRST TIME IN LOOP
SELECT @INDEX = 1
-- following line added 10/06/04 as null
-- values cause issues
IF @String IS NULL RETURN
WHILE @INDEX !=0
BEGIN
-- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER
SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@INDEX - 1)
ELSE
SELECT @SLICE = @STRING
-- PUT THE ITEM INTO THE RESULTS SET
INSERT INTO @Results(Items) VALUES(@SLICE)
-- CHOP THE ITEM REMOVED OFF THE MAIN STRING
SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END
|
|
|
|
|
Your @ExcelDataInXml string is longer than 4000 characters, and your Split function only accepts 4000 characters.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hi,
I have an ID field and it has been set to increment by 1 every time a record is added.
When I exported this table to another database server, it "lost" this identity. Now when I tried to select Modify from the menu, I keep on getting a SQL problem and then management studio closes. So my only other solution is to use a sql script to change this identity to IDENTITY (1, 1).
How do I do this??
The table name is Orders, and the ID field is OrderID_PK int, this is the primary key.
How do I keep the identity as it is when I import a table from one database to another??
I am using SQL Server 2005.
Regards,
ma se
|
|
|
|
|
When you import the table, try Copy object and data between SQL Server databases rather than just Copy table(s) and view(s) from the source database.
Check this out too: DBCC CHECKIDENT (Transact-SQL) [^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hi
I get this exception .....sametime error: DeleteCommand affected 0 of the expected 1 posts.
Think i need commands for a commandbuilder object that doesn't include optimistic concurrency
i have primarykey in the table and so on !
sSql=?????
SelectCommand = New OleDb.OleDbCommand(sSql, con)
sSql=?????
DeleteCommand = New OleDb.OleDbCommand(sSql, con)
sSql = "Update (Postaddresser) SET Priority = @Priority, Id = @Id,Firmname = @Firmname,Mailaddress = @Mailaddress, " & _
"WHERE (Id = @Original_Id);" & _
"SELECT Priority,Id,Firmname,Mailaddress" & _
"FROM Postaddresser WHERE (Id = @Id)"
UpdateCommand = New OleDb.OleDbCommand(sSql, con)
rgds
|
|
|
|
|
Hi,
Iam using PUSH model to create my crystal report document.
The stored procedure which iam using returns a refcursor.
The first 3 columns of the table(FirstName,MiddleName and LastName) are combined as returned as single column,similarly columns address1,address2,city,state and zipcode are returned as single column.
Here is the Code:
OracleConnection cnOracle=new OracleConnection(connectionString);
cnOracle.Open();
OracleCommand cmdRegistrant = new OracleCommand("Pkg_WRTS_Retrieve.prc_getregdata", cnOracle);
cmdRegistrant.CommandType = CommandType.StoredProcedure;
try
{
OracleParameter paramFirstName=new OracleParameter("i_first_name",OracleDbType.Varchar2,50,ParameterDirection.Input);
if(txtFirstname.Text.Equals(string.Empty))
paramFirstName.Value=string.Empty;
else
paramFirstName.Value=txtFirstname.Text;
OracleParameter paramLastName=new OracleParameter("i_last_name",OracleDbType.Varchar2,50,ParameterDirection.Input);
if(txtLastname.Text.Equals(string.Empty))
paramLastName.Value=string.Empty;
else
paramLastName.Value=txtLastname.Text;
OracleParameter paramCountyName=new OracleParameter("i_county_name",OracleDbType.Varchar2,20,ParameterDirection.Input);
if(txtCounty.Text.Equals(string.Empty))
paramCountyName.Value=string.Empty;
else
paramCountyName.Value=txtCounty.Text;
OracleParameter paramCityName=new OracleParameter("i_city",OracleDbType.Varchar2,50,ParameterDirection.Input);
if(txtCity.Text.Equals(string.Empty))
paramCityName.Value=string.Empty;
else
paramCityName.Value=txtCity.Text;
OracleParameter paramCompany=new OracleParameter("i_compent_name",OracleDbType.Varchar2,200,ParameterDirection.Input);
if(txtCompany.Text.Equals(string.Empty))
paramCompany.Value=string.Empty;
else
paramCompany.Value=txtCompany.Text;
// create parameter object for the output
OracleParameter paramResultSet = new OracleParameter();
paramResultSet.OracleDbType=OracleDbType.RefCursor;
// this the output parameter which is returned from the stored procedure
paramResultSet.Direction = ParameterDirection.Output;
// add the parameter to the collection
cmdRegistrant.Parameters.Add(paramFirstName);
cmdRegistrant.Parameters.Add(paramLastName);
cmdRegistrant.Parameters.Add(paramCountyName);
cmdRegistrant.Parameters.Add(paramCityName);
cmdRegistrant.Parameters.Add(paramCompany);
cmdRegistrant.Parameters.Add(paramResultSet);
//Execute the CommandWrapper
OracleDataAdapter daUserDetails=new OracleDataAdapter(cmdRegistrant);
dataSet = new DataSet();
daUserDetails.Fill(dataSet,"WRTS_REGISTRANT");
RegReport = new RegistrantReportViewer();
RegReport.SetDataSource(dataSet.Tables[0]);
//RegReport.SetDataSource(dsReport);
RegistrantViewer.Visible=true;
RegistrantViewer.ReportSource = RegReport;
When i run the application the field's name and address are not displayed in the report,but all the other columns are displayed.
I think its because the datatabe has a combined value of 3 columns but im not able to display it in report properly.Similar for address column also.
Can anyone tell me how to map the datatable column to crystal report column so that the data will be displayed?????
Any reply will be appreciated!!!
Thanks,
Ratish.
Ratish
|
|
|
|
|
hi,
How to overcome this error
"TRANSACTION PROCESS ID 63 WAS DEADLOCKD ON LOCK RESOURCES WITH ANOTHER
PROCESS AND HAS BEEN CHOSEN AS THE DEADLOCK VICTIM.RETURN THE TRANSACTION"
Pls reply
Kavitha
|
|
|
|
|
Do you understand how a deadlock occurs?
Steve
|
|
|
|
|
A deadlock happens because two processes are locking ojects that the other needs. Essentially neither can continue until the other has completed. Since neither process can continue, then also neither process can complete. SQL Server will detect this and choose one process as the victim and cancel its transaction.
To prevent this happening in the first place you should try and ensure that all access to objects (e.g. tables) happen in the same sequence in all transactions. That is, if you have a transaction that updates table A then table B it will potentially deadlock with another transaction that updates table B then table A.
|
|
|
|
|
Hi,
i am geting this warning when i am sorting table through storedprocedure.
Warning: The table '#MM' has been created but its maximum row size (8186) exceeds the maximum number of bytes per row (8060). INSERT or UPDATE of a row in this table will fail if the resulting row length exceeds 8060 bytes.
Plz help me out it's urrgent
|
|
|
|
|
SQL Server does not allow a row to span multiple physical file pages, which are 8KB in size. Therefore the row must be smaller than 8KB, minus a certain amount of per-page overhead, to fit on a single page. Temporary tables can potentially still be written out to disk, they just end up in tempdb 's files.
The total size of all fixed-size fields, plus the maximum size specified for nvarchar, varchar and varbinary fields (plus a little overhead taken by nullable columns and the lengths and offsets of variable-length fields), exceeds the maximum allowed size. However, this is not in itself an error, because it's rare to use the maximum size of all variable-length fields in a single record. If you do, however, any INSERT or UPDATE statement where the lengths of the actual fields exceeds the limit will fail.
Solutions: reduce the number of fields in the table, reduce the maximum lengths of the fields, or change some fields to text , ntext or image types (which are allowed to be stored outside the page containing the rest of the row data).
|
|
|
|
|
I have SerialNumber(SN) ,city ,Country,version ,Region,,,etc in
parent table
For each SN in connectrix table there are multiple switch in
switch_header table. the details of switches are stored in
switch_details table.
For each switch we have different Frus that is stored in Fru table
that has information about fru details
I need to display Connectrix information along with their switches
and fru information as per search criteria.
When I Joined above 4 tables I am getting all the parent column as
repetation which I don't want to happen.
But some how user should understand the situation such that records
should return single SNO, and multiple switchsns ,multiple frus
I tried to populate data in heiarchial HTML table mannar using DataSet
But Gave up.
Is there any methodology from back end?
Any ideas on this?
Thanks in advance.
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
This sounds to be more of a question for .NET group or something.
One option in SQL Server would be to output more than one recordset from a procudure or something, but you are still dealing with a display issue which has everything to do with the application and nothing to do with SQL Server.
Since it is in the ADO group. Look into Nested Repeaters and you should find your answer there.
|
|
|
|
|
i need to wirte these stored procedures
1-
Add recored to the table
2-
use the above sp's to add the full data for the item in the tables(ks_media_item ,ks_media_item_content)
3-
update the data in the table ks_media_item
-if the value of item_no not found print msg "record not found "
-the columns (update_By , Udated_Date)willfill
4-
Rturn the all data Based on the Item_No from the tow tables
the tables are :
Ks_Media_Item(Item_no,Description,Added_Date,
Added_By,Update_By,Updated_Date)
2-
Ks_Media_Item_Content(Item_no,content,Text_Length)
i hope to answer me
thank you all
yazan_shalabi
|
|
|
|
|
yazan_zahi wrote: i hope to answer me
I'm still looking for the question.
|
|
|
|
|
sounds to me like you are hoping someone will do your work for you?
|
|
|
|
|
Sage wrote: sounds to me like you are hoping someone will do your work for you?
Answering people's questions is not my work. I do it voluntariliy because I enjoy helping people. However, people must first help themselves before I can help them.
|
|
|
|
|
You know that that post had been directed to Yazan dont you? I also enjoy helping others, learn that is. I dont enjoy helping other people do their work, unless I am getting paid.
|
|
|
|
|
Sage wrote: You know that that post had been directed to Yazan dont you?
I wondered about that. You replied to my message though (so I got the email notification), not Yazan's message.
|
|
|
|
|
we write the stored procedure in sqlserver2000
(update,insert,select)that better than write the statment it in asp.net code why ???
|
|
|
|
|
SP is a set of precompiled code.
It imporoves performance of the application
SPs can be reusable.
If any DB logic changes it's ok if we change in procedure it self rather than modifying all the queries.
SP makes maintainability also easier
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
Also, if you revoke access to the actual tables to the users and do everything through Stored Procedures then you increase the security of the application because then the the users can only do what is specified in the Stored Procedure and cannot do anything else.
|
|
|
|
|
add recored to the table ks_Media_item
-if the same Item_no Value Found in the table Print msg"Record found"and exit the procedure
-the columns (Updated_by,Updated_Date)will be null
the tabel columns (Item_no,Decription,Added_Date,
Added_By,Updated_by,Updated_Date)
thank you;
yazan_shalabi
|
|
|
|
|