473,889 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Declare an array of int in SQL Server

Hi All,
I want declare an array of int in SQL Server
please help me to convert the following code from VB to TSQL
Dim md_mon(12) As Integer
md_mon(1) = 31
Jul 20 '05 #1
4 71302
There are no arrays in SQLServer. Maybe if you explain your requirements
someone can suggest another alternative.

David Portas
SQL Server MVP
Jul 20 '05 #2
Majid Mohammadian (Mo***********@ yahoo.com) writes:
I want declare an array of int in SQL Server
please help me to convert the following code from VB to TSQL
Dim md_mon(12) As Integer
md_mon(1) = 31

SQL and Visual Basic are languages that work from very different mindsets,
and for a successful rewrite from VB to SQL it is often best to start from
the beginning. In VB you would typically to things in loops, to iterate
over items in a set of data, but in SQL you should always strive to use
commands that operate on the entire set at the same time. That is when
you actually win performance.

SQL does not have arrays, but there are tables, and tables are a lot broader
concept than array. So in this case:

noofdays tinyint NOT NULL)

Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
Jul 20 '05 #3
If the purpose of your array was to store the number of days in each month
then as an alternative in TSQL you could calculate the number of days for a
given month like this:

SET @dt = '20040101' -- January 2004


David Portas
SQL Server MVP
Jul 20 '05 #4
Erland Sommarskog <so****@algonet .se> wrote in message
SQL does not have arrays, but there are tables, and tables are a lot broader
concept than array. So in this case:

noofdays tinyint NOT NULL)

FYI: You can also create a table variable, like:

MonthNo int,
NumDays int

.... and then use it like any real table:

INSERT INTO @tblMonth...
SELECT * FROM @tblMonth...
Jul 20 '05 #5

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

Similar topics

by: Philipp | last post by:
Hello, I've got a class Lattice which is declared like that: // file: lattice.h class Lattice:public EventChooser{ public: Lattice(LatticeParameters* params); virtual ~Lattice(); // (...snip...)
by: Youn ki beom | last post by:
class A { A() {} }; class B { A* array; A* p_toA;
by: b83503104 | last post by:
Previously, when my constructor had no arguments, I used this to declare my objects: MyClass myObject; Now, my constructor has arguments (MyClass::MyClass(int someVariable)), how do I declare my objects? I tried MyClass myObject(100); and
by: Laszlo Szijarto | last post by:
Thank you in advance, I am trying to populate a HashTable object with a value that's an array, but I don't want to put in two lines of code for each entry. rather than saying int value = {1,2,3}; hashTable.Add("test",value);
by: Petez | last post by:
Hi, I want to declare array of System::Data::DataRow but how? With single variable I write System::Data::DataRow^ aRow but statement System::Data::DataRow^ - not works. System::Data::DataRow* - not works. System::Data::DataRow^^ - not works. I need this array for store result of DataTable->Rows->Select(...) Thanks, Peter
by: John A Grandy | last post by:
inside a procedure , i code Dim values(1) As Object .... various other lines of code ... ReDim values(2) As Object
by: james | last post by:
Hi, Just looking here: http://msdn2.microsoft.com/en-us/library/9b9dty7d.aspx I can't quite see what I want to do. I want an array of Booleans of length 102, all initially "false". I have this so far: public bool Monitors = new bool; but if I add on the end of that : {false}, I get a compile error of "Invalid
by: pentahari | last post by:
My function is: Function test(optional ByVal arr1() as System.Array) End Function how to declare the array as optional? i know that optional variable must be constant value, but i don't know the constant value to the array
by: robert.waters | last post by:
I have to parse a binary file having a number of fixed records, each record containing datas in fixed positions. I would like to parse this binary file into an array of structures having members that represent those fields, so that I can access the records in a meaningful way. Using C, I would have defined a struct that I could cast a byte array into, which held exactly one of these fixed records. The struct would be defined as such:...
by: lenniekuah | last post by:
Hullo Good Friends, I need your help, Please Help me. I am using C#Net2008 to develop Window Application. I have not create ARRAY before. The Project Manager asked me to use ARRAY to contain the following example data type from Call Center Table: 10331 <-- Client Driving Licence 16/10/2010 <-- Date Called
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.