|
is it possible to get the data of table except for one column?
that is, if I have a table with column names ID, Name, Address, ...
How can I get the data of all columns except for ID column?
and, how to get the column names(not the data) ?
for table names I found the following:
Select * from sysobjects where [type] in ('U')
|
|
|
|
|
Exceter wrote:
is it possible to get the data of table except for one column?
that is, if I have a table with column names ID, Name, Address, ...
How can I get the data of all columns except for ID column?
Only by specifying all the columns. Note that using the * operator can be a bit costly, because the server has to enumerate the columns - it's usually better to specify them all anyway.
and, how to get the column names(not the data) ?
for table names I found the following:
Select * from sysobjects where [type] in ('U')
See http://msdn.microsoft.com/msdnmag/issues/03/08/CodeGeneration/default.aspx[^] for more details.
|
|
|
|
|
Mike Dimmick wrote:
How can I get the data of all columns except for ID column?
Just want to add that it's a bad practice to use SELECT * . Think what will happen with your code if you rename some of your table columns or reorder them.
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Alexandre Kojevnikov wrote:
Think what will happen with your code if you rename some of your table columns or reorder them.
So what? If you'll specify all columns in SELECT, you will still need to change your code, then what's the matter? Mike actually pointed the right issue about performance of "*"
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Philip Patrick wrote:
you will still need to change your code
Exactly. But if you don't use SELECT * you will get errors in your SQL query and will have one more possibility to think about consequences of column renaming and adapt the client code appropriately.
With SELECT * you might forget about adapting the client code. And in many cases you won't even see compile-time errors.
If you are just reordering columns, you won't have to change anything.
Performance is also an important issue of course.
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Does anyone know how to detect what MDAC version a server is running?
|
|
|
|
|
RegistryKey key = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Microsoft\DataAccess" );
string version = key.GetValue( "FullInstallVer", "0.0.0.0" ) as string;
key.Close();
All this kind of stuff is on MSDN.
Bo Hunter
|
|
|
|
|
Programmatically, or for diagnostic purposes?
For diagnostics, use the MDAC Component Checker[^].
The snapshots included with the tool can be somewhat misleading - I don't think I've ever had any system installation, including a completely clean install, report no errors with this tool. But it'll make a fairly good identification.
|
|
|
|
|
I have a varchar(30) variable which holds data I want, a '$' and then some more data I want. Basically, I'm trying to cheat and return 2 dates from one function, and this seemed one way to do it.
My problem is this - I want to get the two dates in the sp this string is returned to. I was thinking of finding the position of the '$', then the characters before it will be the first date, and the characters between it and the end of the string will be the second date. The problem is, I'm having trouble getting the position of the '$'.
Any ideas?
I hope I'm making sense
Look at the world about you and trust to your own convictions. - Ansel Adams
Photography[^]
|
|
|
|
|
--first date
SUBSTRING(1, CHARINDEX('$', variablename))
--second date
SUBSTRING(CHARINDEX('$', variablename) + 1, LEN(variablename) - CHARINDEX('$', variablename))
You may have to adjust by adding/subtracting 1 to get proper results
|
|
|
|
|
Thought of using a table-valued function?
CREATE FUNCTION dbo.fnGetTwoDates
(
@searchCriteria varchar(30)
)
RETURNS @twoDates TABLE
(
FirstDate datetime,
SecondDate datetime
)
AS
BEGIN
INSERT INTO @twoDates
SELECT
RETURN
END
Usage:
SELECT FirstDate, SecondDate
FROM dbo.fnGetTwoDates( 'criteria' ) Now, if only we could pass tables INTO stored procedures as parameters - I'm stuck with using temporary tables with fixed names in order to modularise some very large (>1000 line) procedures.
|
|
|
|
|
SELECT [ID], Title, NodeType, ParentID, [Language], Description FROM SourceCode WHERE Title LIKE '%Title%' OR Code LIKE '%Title%' AND Language = 1 OR Language = 2 OR Language = 3 OR Language = 4 OR Language = 5 AND NodeType = 1 OR NodeType = 2 OR NodeType = 3 OR NodeType = 4 OR NodeType = 5 OR NodeType = 6 AND ParentID = 4 OR ParentID = 6
Do the numbers have to be quoted?
Any Suggestions?
Thank You
Bo Hunter
|
|
|
|
|
AND operator has a higher priority than OR . You might want to use parentheses:
SELECT [ID], Title, NodeType, ParentID, [Language], Description
FROM SourceCode
WHERE (Title LIKE '%Title%' OR Code LIKE '%Title%')
AND (Language = 1 OR Language = 2 OR Language = 3 OR Language = 4 OR Language = 5)
AND (NodeType = 1 OR NodeType = 2 OR NodeType = 3 OR NodeType = 4
OR NodeType = 5 OR NodeType = 6)
AND (ParentID = 4 OR ParentID = 6)
HTH,
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Furthermore, you really ought to use "IN":-
SELECT [ID], Title, NodeType, ParentID, [Language], Description
FROM SourceCode (nolock)
WHERE (Title LIKE '%Title%' OR Code LIKE '%Title%')
AND Language IN (1,2,3,4,5)
AND NodeType IN (1,2,3,4,5,6)
AND ParentID IN (4,6)
#include <beer.h>
|
|
|
|
|
Will the IN operator work in Access?
I forgot to mention that.
And also some of the idetifiers like Language
has to be exscaped. Does that also have to be
exscaped in OleDbParameter like so,
OleDbParameter param = new OleDbParameter( "[Language]", bla bla );
Is this correct?
Thank You
Bo Hunter
|
|
|
|
|
Bo Hunter wrote:
Will the IN operator work in Access?
Yep, it will.
Bo Hunter wrote:
Does that also have to be
exscaped in OleDbParameter
Probably it has to be escaped. This won't hurt anyway
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Hi all,
I'm having the following problem: my site can access the database perfectly, using an ODBC-less connection, but when I try and insert or edit records I get the error "Cannot update. Database or object is read-only." I have changed all permissions in IIS, and in Windows Explorer but I can't seem to get it working. Suggestions please?
The connection string I'm using:
(driver: Microsoft.Jet.OLEDB.4.0)
var sConnectionString = "Provider=" + sDBDriver + "; ";<br />
sConnectionString += "Data Source=" + Server.MapPath("../../bin/db/db.mdb");
Paul
Tiny problem with said member has been corrected. Chris Maunder
modified 18-Jul-18 11:59am.
|
|
|
|
|
Fixed
Paul
Tiny problem with said member has been corrected. Chris Maunder
modified 18-Jul-18 11:59am.
|
|
|
|
|
How?
"Welcome to Arizona! Drive Nice - We're Armed..." - Proposed Sign at CA/AZ Border
|
|
|
|
|
I had to give IUSR_<computername> read and write access to the directory containing the Access DB.
HTH
Paul
Tiny problem with said member has been corrected. Chris Maunder
modified 18-Jul-18 11:59am.
|
|
|
|
|
Ah, of course... I've run into similar fun and games simply hosting files on IIS for public access. I assumed that the Everyone group included IUSR_... but never bothered to look. I still haven't, in fact, but found empirically that adding IUSR access to hosted files suddenly made them accessible from the outside world.
"Welcome to Arizona! Drive Nice - We're Armed..." - Proposed Sign at CA/AZ Border
|
|
|
|
|
|
Hello
I have a problem while trying to edit a record on SQL Server 2000 (Sp 3).
The problem occures, w hen I click to "Return all rows" in the context menu of the table, and I tried to uptade a record .
It occures an error. The error message says : "Transaction cannot start while in firehose mode"
I have researched a little about firehorse, but could not find any useful information.
I look forward to hearing from you
thanks
Best Regards
Emre YAZICI
|
|
|
|
|
Firehose mode or firehose cursor is a forward only readonly way of going throug data.
Is this in Enterprise Manager? Is this problem consistent, or only on a certain table?
|
|
|
|
|
thanks for your help
There are lots of tables, It occures just for ONE table.
We are using a client of a network
The database is on the SERVER of the network
There is a strange thing that I do not understand
I am able to update the record , when I add a new record.
e.g.
There are 10 records
I have added a new one, after I updated the 8th one .
After this there are 11 records, and the 8th record has been updated successfully.
please contact for further information if necessary
Best Regards
Emre YAZICI
|
|
|
|