Tuesday, March 27, 2012
field definitions for all user tables
Thank you in advance for reading this question.
I posted this question in the newbie area, but have not had a response.
Is there a way to get all the fields for all user tables that are returned
when you do sp_help tablename? I think I have found the columns I need in
'syscolumns' but it is not clear to me how to link the table names to that
syscolumns table to get what I need.
My apolgies for the newbie question. Any help is appreciated!
DianeI just replied to the newusers post.
However, to get table names from syscolumns you can simply call the
OBJECT_NAME() function passing in the id column from syscolumns
(although it's more kosher to use the INFORMATION_SCHEMA views). Like this:
select object_name(id) as [TableName], * from dbo.syscolumns
Hope this helps.
*mike hodgson*
blog: http://sqlnerd.blogspot.com
Diane wrote:
>Hello.
>Thank you in advance for reading this question.
>I posted this question in the newbie area, but have not had a response.
>Is there a way to get all the fields for all user tables that are returned
>when you do sp_help tablename? I think I have found the columns I need in
>'syscolumns' but it is not clear to me how to link the table names to that
>syscolumns table to get what I need.
>My apolgies for the newbie question. Any help is appreciated!
>Diane
>
>|||> Is there a way to get all the fields for all user tables that are returned
> when you do sp_help tablename? I think I have found the columns I need in
> 'syscolumns'
I strongly recommend avoiding the sys tables when possible.
How about http://www.aspfaq.com/2177 ?|||my choice is
sp_msforeachtable @.command1 = "sp_help '?' "
--
Regards
R.D
--Knowledge gets doubled when shared
"Aaron Bertrand [SQL Server MVP]" wrote:
> I strongly recommend avoiding the sys tables when possible.
> How about http://www.aspfaq.com/2177 ?
>
>|||> my choice is
> sp_msforeachtable @.command1 = "sp_help '?' "
Well, sp_msforeachtable is convenient, sure. However I have a two issues
with this approach:
(a) it returns a resultset for each table, whereas with
INFORMATION_SCHEMA.COLUMNS you can easily get all the results in a single
set.
(b) it is an undocumented and unsupported feature, so its behavior can
change or it could disappear from the product altogether with a service
pack, security release or new version of SQL Server.
Monday, March 12, 2012
fastest way to recieve results?
I want to call a stored proc. on SQL 2000 from VC 6.0. This stored proc
can return 1-4 rows. After extensive reading and overwhelming myself with
help files from MSDN 6.0, MDAC 2.8, SQL 2000 and hte platform SDK, I want
to optimize my software performance. I want to do only one round trip to
the server which will include a request to the server and its response
should be all 4 rows of data as a block.
some help files say for read-only-Fast-forward cursors wit ha small result
set, client mode with auto-fetch option is the best way. other help files
say odbc client mode library cursors are slower and way more memory
intensive than native SQL server libraries so caution should be used. what
should i do?
currently i use:
SQLSetConnectAttr(*hdbc, SQL_ATTR_ODBC_CURSORS, (SQLPOINTER)
SQL_CUR_USE_ODBC,0); ////odbc test
SQLDriverConnect(...)
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE, (PTR)sizeof(SQLARRAY), 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (PTR) 4, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, (SQLPOINTER)RowStatusArray,
0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &NumRowsFetched, 0);
is this optimized?
LeonLeon McCalla wrote:
> Hi,
> I want to call a stored proc. on SQL 2000 from VC 6.0. This stored proc
> can return 1-4 rows. After extensive reading and overwhelming myself with
> help files from MSDN 6.0, MDAC 2.8, SQL 2000 and hte platform SDK, I want
> to optimize my software performance. I want to do only one round trip to
> the server which will include a request to the server and its response
> should be all 4 rows of data as a block.
Why? What do you have that is so time critical?
Aaron|||I'm working on a calling card application. millions of callingcards are
already on the street and sometimes i get 10-20 requests per second.
PS i already solver the problem.
Leon
"Aaron Lawrence" <aaronlNOT@.HEREintegration.co.nz> wrote in message
news:eu5N0MZ$GHA.3836@.TK2MSFTNGP02.phx.gbl...
> Leon McCalla wrote:
proc[vbcol=seagreen]
with[vbcol=seagreen]
want[vbcol=seagreen]
to[vbcol=seagreen]
> Why? What do you have that is so time critical?
> Aaron
>
fastest way to recieve results?
I want to call a stored proc. on SQL 2000 from VC 6.0. This stored proc
can return 1-4 rows. After extensive reading and overwhelming myself with
help files from MSDN 6.0, MDAC 2.8, SQL 2000 and hte platform SDK, I want
to optimize my software performance. I want to do only one round trip to
the server which will include a request to the server and its response
should be all 4 rows of data as a block.
some help files say for read-only-Fast-forward cursors wit ha small result
set, client mode with auto-fetch option is the best way. other help files
say odbc client mode library cursors are slower and way more memory
intensive than native SQL server libraries so caution should be used. what
should i do?
currently i use:
SQLSetConnectAttr(*hdbc, SQL_ATTR_ODBC_CURSORS, (SQLPOINTER)
SQL_CUR_USE_ODBC,0); ////odbc test
SQLDriverConnect(...)
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE, (PTR)sizeof(SQLARRAY), 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (PTR) 4, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, (SQLPOINTER)RowStatusArray,
0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &NumRowsFetched, 0);
is this optimized?
Leon
Leon McCalla wrote:
> Hi,
> I want to call a stored proc. on SQL 2000 from VC 6.0. This stored proc
> can return 1-4 rows. After extensive reading and overwhelming myself with
> help files from MSDN 6.0, MDAC 2.8, SQL 2000 and hte platform SDK, I want
> to optimize my software performance. I want to do only one round trip to
> the server which will include a request to the server and its response
> should be all 4 rows of data as a block.
Why? What do you have that is so time critical?
Aaron
|||I'm working on a calling card application. millions of callingcards are
already on the street and sometimes i get 10-20 requests per second.
PS i already solver the problem.
Leon
"Aaron Lawrence" <aaronlNOT@.HEREintegration.co.nz> wrote in message
news:eu5N0MZ$GHA.3836@.TK2MSFTNGP02.phx.gbl...[vbcol=seagreen]
> Leon McCalla wrote:
proc[vbcol=seagreen]
with[vbcol=seagreen]
want[vbcol=seagreen]
to
> Why? What do you have that is so time critical?
> Aaron
>
Friday, March 9, 2012
Fastest method for Inserting 1 million records into SQL Database
Have you tried BCP or BULK INSERT? It sounds like you're inserting the data
row-by-row using VB.NET; perhaps you can get away with a BULK INSERT using a
format file to tweak the data? It would probably also be faster if you BULK
INSERT the data in its "raw" form into a temporary table and then move it to
its final destination using INSERT ... SELECT, and do any data modifications
necessary in the SELECT.
"BradC" <BradC@.discussions.microsoft.com> wrote in message
news:F2AA271E-A8B7-448F-83BC-900EFFB679E8@.microsoft.com...
> I am reading a text file and modifing the data to match fields in a SQL
2000 Database then inserting the record in. I am using vb.net and have tried
various methods but all are to slow. I would appreciate any help anybody
could offer.
Fastest method for Inserting 1 million records into SQL Database
Database then inserting the record in. I am using vb.net and have tried var
ious methods but all are to slow. I would appreciate any help anybody could
offer.Have you tried BCP or BULK INSERT? It sounds like you're inserting the data
row-by-row using VB.NET; perhaps you can get away with a BULK INSERT using a
format file to tweak the data? It would probably also be faster if you BULK
INSERT the data in its "raw" form into a temporary table and then move it to
its final destination using INSERT ... SELECT, and do any data modifications
necessary in the SELECT.
"BradC" <BradC@.discussions.microsoft.com> wrote in message
news:F2AA271E-A8B7-448F-83BC-900EFFB679E8@.microsoft.com...
> I am reading a text file and modifing the data to match fields in a SQL
2000 Database then inserting the record in. I am using vb.net and have tried
various methods but all are to slow. I would appreciate any help anybody
could offer.
Sunday, February 26, 2012
Fast counting of records
can retrieve a count of the last recordset you opened.
For example:
I've got a stored procedure that returns a recordset using the TOP 10
so I only get the top 10 records. I need to know the recordcount but I
dont want to reuse the SELECT statement because its quite complex.
Any ideas?
What does @.@.Count do?
Thanks in advance"Samuel Hon" <noreply@.samuelhon.co.uk> wrote in message
news:c8672b7d.0309110815.2fba8c32@.posting.google.c om...
> I seem to remember reading many moons ago about a function where you
> can retrieve a count of the last recordset you opened.
> For example:
> I've got a stored procedure that returns a recordset using the TOP 10
> so I only get the top 10 records. I need to know the recordcount but I
> dont want to reuse the SELECT statement because its quite complex.
> Any ideas?
> What does @.@.Count do?
> Thanks in advance
@.@.ROWCOUNT
Simon