Showing posts with label columns. Show all posts
Showing posts with label columns. Show all posts

Thursday, March 29, 2012

Field limits

Simple question, I think.
What is the # of fields (columns) SQL Server 2000 is
limited to in one table ?1024 columns.
-Sue
On Mon, 11 Aug 2003 16:30:28 -0700, "Michael forer"
<mykiv@.hotmail.com> wrote:
>Simple question, I think.
>What is the # of fields (columns) SQL Server 2000 is
>limited to in one table ?sql

Monday, March 26, 2012

fetching data in a datatable

hello, i'm using asp.net 2 with VB, i have a table in my db named 'exams' and i have 6 columns in this table one for question number and one for the question and 3 columns for 3 answers and a last column for the right answer, now in my page i want to show 7 questions and each question has 3 answers that i can choose between them i want the question appear in datatable and the answers in radiolist i have a little code for that but it shows an error it says "no row at position 1" so hope u guys can help :

Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnetdb.mdf;Integrated Security=True;User Instance=True")
Dim a As New ArrayList(8)
Dim i As New Integer
i = 0
Dim d As New DataSet()
Dim cmd As New SqlDataAdapter("select top(7) question from exams", con)
cmd.Fill(d, "exams")
a.Add(d.Tables.Item(0, 1))
i = i + 1
Dim ta As New DataTable
ta.Rows(i).Item(0).text = d.Tables(0).Rows(0)(i)

and by the way this code is for the questions i still dont have the code for the answers that will appear in a radiolist hope u can help .thanksnobody can help?!!!!|||Are you sure the sql query did return result?
This error always occurs if you specify an index that is out of range.sql

fetch results of a cursor to a temporary DB for manipulation

Hi all

I want to put the fetch results of a cursor to a temporary DB for manipulation, Im selecting all columns from the table in the cursor and the number of total columns is unknow.

Please guide me on how this could be done...

Thanks in advance

Regards

BennyGet rid of the cursor and use a select into statement with the same query to create a table in the temp database.

If you want to perform row by row oprerations on the resultset use the identity function to create an identity on it then you can loop through that without need for a cursor.

Monday, March 12, 2012

fastest way to do this?

I'm trying to find out what's the fastest way to execute such a query.
Presumely I have 1 denormalized table (TableTest) with 2 columns A and B
A - Nvarchar(50)
B - smalltimestamp
I have 10 records in this table out of which column A has 2 distinct values
(Test1 and Test2) and B has 10 distinct values, so it might look something
like this
A B
Test1 2006-03-31 15:21:00
Test1 2006-03-23 15:21:00
Test1 2006-02-01 15:21:00
..
Test2 2006-04-01 15:21:00
Test2 2006-03-31 15:12:00
Test2 2006-01-28 13:21:00
Now I want to execute a query on this table to return the latest occurrence
of A and B, so the results should look like this
A B
Test1 2006-03-31 15:21:00
Test2 2006-04-01 15:21:00
What is the fastest way to do this? I've tried a couple of methods but
they're all slow.I'd say that the construct which is designed for this type of operation has
the best chance for best
performance:
SELECT A, MAX(B)
FROM tblname
GROUP BY A
And then you make sure you have good indexes to support that query. Perhaps
a non-clustered index on
(A,B) is the best choice here.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Nestor" <n3570r@.yahoo.com> wrote in message news:%23N1WqPJVGHA.4436@.TK2MSFTNGP10.phx.gbl..
.
> I'm trying to find out what's the fastest way to execute such a query.
> Presumely I have 1 denormalized table (TableTest) with 2 columns A and B
> A - Nvarchar(50)
> B - smalltimestamp
> I have 10 records in this table out of which column A has 2 distinct value
s (Test1 and Test2) and
> B has 10 distinct values, so it might look something like this
> A B
> Test1 2006-03-31 15:21:00
> Test1 2006-03-23 15:21:00
> Test1 2006-02-01 15:21:00
> ..
> Test2 2006-04-01 15:21:00
> Test2 2006-03-31 15:12:00
> Test2 2006-01-28 13:21:00
> Now I want to execute a query on this table to return the latest occurrenc
e of A and B, so the
> results should look like this
> A B
> Test1 2006-03-31 15:21:00
> Test2 2006-04-01 15:21:00
> What is the fastest way to do this? I've tried a couple of methods but the
y're all slow.
>
>