|
hi all
can anyone tell me how to count the number of records(rows)in a table without using "COUNT" aggregate function.
thanx in advance.
pintoo
|
|
|
|
|
chithra.r wrote: without using "COUNT"
What is that you are trying to do? If you are writing a proc, you may use @@RowCount[^]
Pl: Read through the documentation listed in the above URL, to know the scenarios where it can be applied.
Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime.
Pradeep Joe
|
|
|
|
|
@@Rowcount is only gives you the number of rows affected by the last query, for example
select count(*) from table1
will give an @@RowCount of 1
The best way I know of without using select count(*) is
EXEC sp_spaceused 'tablename'
which gives you
name rows reserved data index_size unused
If you only want an approximate count
select max(rows)<br />
from sysindexes <br />
where indid < 2<br />
and id = object_id('TableName')
(this is not 100% accurate as rows sysindexes is not always updated)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
What's wrong with COUNT()?
|
|
|
|
|
I wonder if you are misunderstanding what you can do with COUNT
Try this query and see if the results it gives you are what you want:
select 'Rows in table:'+cast((select count(*) from tablename)as varchar(20))
You always pass failure on the way to success.
|
|
|
|
|
This might work instead
Select MAX(rowid)-MIN(rowid) from table
|
|
|
|
|
I want to calculate the percentile. I need any function or procedure to calcuate percentile. Thanks in advance....
Do good and have good.
|
|
|
|
|
Google[^]
Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime.
Pradeep Joe
|
|
|
|
|
Be a bit more elaborate about your question...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
hi,
in my app , i expect; when user write Record Number a textbox then click delete button i want to be deleted that record.
Code ;
OleDbCommand delCmd = new OleDbCommand("DELETE FROM FAALIYET WHERE KNO =" + txtKayitNo, Rapor);
Rapor.Open();
delCmd.ExecuteNonQuery();
Getting Error ; 'KNO =System.Windows.Forms.TextBox, Text: 6' syntax error in the query.
whats the problem?
|
|
|
|
|
try changing code to:
OleDbCommand delCmd = new OleDbCommand("DELETE FROM FAALIYET WHERE KNO =" + txtKayitNo.Text, Rapor);
it's much better and safer to use parameterized queries.
|
|
|
|
|
lol this is so funny mistake i forget put .text in front of the txtKayitNo. Thanx mann
|
|
|
|
|
hello,
i've a question that is there any way by which i can store a string direct to database instead of table ? something like settings in C#
because i dont want to make a table only for that string
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
A database is made up of tables. That's how it works. You need to define a table to have a place to store your data. Perhaps the DB is the wrong place for what you want to store, or you need to define a table of key/value pairs to let you store unique values ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
nono, i just want to store a string with every database, something like a tag property with every control in C#
it will be strange that if someone make a table only for a string
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: it will be strange that if someone make a table only for a string
Maybe, but this is the right way
|
|
|
|
|
Extended properties can be used for storing metadata. As people have said though - if this information is part of your domain it should be in the model - even if it is Config ( Key, Value)
|
|
|
|
|
Config ( Key, Value) ?????
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
as in make a TABLE Config ( PK Key NVARCHAR(), Value NVARCHAR() )
|
|
|
|
|
so you want to say that i should make a table that have these columns
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Yeah, its just the way to do it.
If you have information to store thats "about a table" for example... say a comment on the table, then you can use extended properties. They arent really used for storing data though, just metadata.
|
|
|
|
|
Why dont you try to Save this in INI file with Key\Value Pair
where Key is DB name and Corresponding you want to save.
Develop2Program & Program2Develop
|
|
|
|
|
i thought so but i'm afraid, if any error occures after detaching any database then who will rollback the transaction ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I would like to make a backup CD of SQL Server that I installed onto my laptop. I did this when I had an MSDN subscription and it has run out. Other than the main program files and databases themselves, is there anything else I need to copy?
|
|
|
|
|
You may need to backup the master database as well if you need to keep logins and permissions.
|
|
|
|