473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQL server stored procedure question

Hi,

I have a problem here when I code stored procedure to manipulate data
in database. My idea is that if I can save all data I get in some
arrays I should be able to manipulate the arrays directly. But I do
not know how to declare arrays in SQL server stored procedure and do
not know other ways to do the same thing. Please help me out. Thanks
in advance.

-mingzhen
Jul 20 '05 #1
4 8774
There are no 'arrays' or array datatypes in SQL Server. Generally developers
come up with many work arounds using strings, XML etc. You can find an
exhaustive article at :
http://www.algonet.se/~sommar/arrays-in-sql.html

--
- Anith
( Please reply to newsgroups only )
Jul 20 '05 #2
[posted and mailed, please reply in public]

mingzhen (mi*********@yahoo.com) writes:
I have a problem here when I code stored procedure to manipulate data
in database. My idea is that if I can save all data I get in some
arrays I should be able to manipulate the arrays directly. But I do
not know how to declare arrays in SQL server stored procedure and do
not know other ways to do the same thing. Please help me out. Thanks
in advance.


It sounds like you are used to programming in 3GL, and want to apply
the same methods there. Actually, there are arrays in SQL, just
there right before your eyes. But they are not called arrays, but
tables, and are in many extents much more powerful than arrays. Arrays
you typically handle sequentially. While you can do this with a table,
you can also apply operations on many rows at the same time, which is
usually several magnitudes faster than sequential processeing.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
Yes, I know that sometimes table can be more flexible than arrays. But
my main problem is that I want to abstract data from each record in
the table, and concatenate these dat a into one string. Then I can
compare these strings to chech if there are some duplicate records in
the specific table.

So, my problems are:
1. identify primary key field in a specific table
2. concatenate data from fields except primary key field in one record
into one string, and different strings for different records in the
table

HOw can I do this using table or other methods? Thanks for help.

--mingzhen
Erland Sommarskog <so****@algonet.se> wrote in message news:<Xn********************@127.0.0.1>...
[posted and mailed, please reply in public]

mingzhen (mi*********@yahoo.com) writes:
I have a problem here when I code stored procedure to manipulate data
in database. My idea is that if I can save all data I get in some
arrays I should be able to manipulate the arrays directly. But I do
not know how to declare arrays in SQL server stored procedure and do
not know other ways to do the same thing. Please help me out. Thanks
in advance.


It sounds like you are used to programming in 3GL, and want to apply
the same methods there. Actually, there are arrays in SQL, just
there right before your eyes. But they are not called arrays, but
tables, and are in many extents much more powerful than arrays. Arrays
you typically handle sequentially. While you can do this with a table,
you can also apply operations on many rows at the same time, which is
usually several magnitudes faster than sequential processeing.

Jul 20 '05 #4
mingzhen (mi*********@yahoo.com) writes:
Yes, I know that sometimes table can be more flexible than arrays. But
my main problem is that I want to abstract data from each record in
the table, and concatenate these dat a into one string. Then I can
compare these strings to chech if there are some duplicate records in
the specific table.

So, my problems are:
1. identify primary key field in a specific table
2. concatenate data from fields except primary key field in one record
into one string, and different strings for different records in the
table

HOw can I do this using table or other methods? Thanks for help.


I'm really sure that I follow, so I like to make the following standard
suggestion. Post a script that contains CREATE TABLE statement(s) for
the involved table(s) (preferably simplified) and INSERT statements
with sample data. With the script, include the desired result.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
3
by: Niyazi | last post by:
Hi, Me again. I want to create a SQL Server StoreProcedure and I want to access it with ADO.NET. I am using VB.NET. Creating StoreProcedure it was easy but my question is this. I have table...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
5
by: Alan T | last post by:
Currently our SQL Server 2000 database table field is using char to store as boolean, ie. "T" or "F". Now we change the field from char to bit field. I am not sure how it has impact on the C#...
4
by: eighthman11 | last post by:
I'm calling a stored procedure on a sql server from an access application. I just need the stored procedure to run I do not need any data returned from the stored procedure to my Access...
8
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table,...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.