|
In your SQL you can concatonate the fields together to give you an additional column.
select cola + ',' + colb + ',' + colc + ',' + cold as 'ConcatCol'<br />
from tablename
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have a table which have person's name as Prefix, firstname, lastname, address as three
different columns.
I want to get all records when fire a query like
SELECT * from Persons where name= 'abcd'
I want such query which can search in all three columns, it means abcd can be in
Prefix, firstname or lastname column.
Actually I have a page in which there are some text boxes which accepts some inputs and
based on that inputs displays matching records in GridView.
Suppose someone entered 'Ind', so my query should find records in all three columns of name.
And if someone entered record in first text box say name and nothing is entered in address text box, then
the records matching with that name with all addresses should get displayed.
How can I do that?
Thanks in advance,
|
|
|
|
|
I have joined three columns as
SELECT (Prefix+' '+firstname+' '+lastname) from Persons
|
|
|
|
|
Not too sure what you wanted, but here's what I think you are asking for:
SELECT (Prefix+' '+firstname+' '+lastname) from Persons Where Prefix like '%abcd%' or firstname like '%abcd%' or lastname like '%abcd%'
|
|
|
|
|
thanks it worked!
|
|
|
|
|
I have an application that uses the OracleClient namespace to connect to Oracle database. the application opens only one connection and keep it open as long as the application is running.
queries that are used in the application are select, insert, update and delete ( approximately 50 queries per minute).
for short period after running the application, everything does OK, but after a long period this application reserves a high CPU percentage from the Oracle Database.
I'm using a static class to represent the Database connection and methods that are used to execute queries, which means that once the method scope is ended the application must garbage collect any resource used at that method.
my question is, what could cause the high usage of the CPU on the Oracle client even though the application is ideal but the connection is still established?
Best Regards,
Ahmad Zuhd
|
|
|
|
|
|
By writing a trigger that does something like delete from mytbl where mydate = '1/1/1900' ???
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
thx....... i have nearly 50 columns in my table and nearly 35 columns "datetime".... how to proceed this?. i need this trigger. i m not familiar with triggers... kindly provide me the exact TRIGGER FUNCTION?
|
|
|
|
|
OK - I got a 1 for helping you because ?
The books online and google explain how to write a trigger. I'd help more, but then I'd just get another one vote for my trouble.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
WASTEEEEEEEEEEEEEEEEEEEEE
|
|
|
|
|
I'm sorry, when I get a 1 for trying to help, on the basis that people can't do any work for themselves, I stop helping.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
|
Me too.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Yup. Judging by your responses, Christian is most definitly wasting his time on you.
|
|
|
|
|
What makes you think demanding code and a response like this will ever get you help here or anywhere else in the world???
|
|
|
|
|
Hi all, I want to load a database column to a dropdownlist.So how to load data to dropdownlist?
DB is MSSQL 2005
Language is C#
thanks
CheeN
|
|
|
|
|
select myCol from myTable and then bind the resultant datatable to the control. You can also set the display and data member if you want, you'll need to do this if you select more than one column.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Hi guys
I need to implement real time data sync of 2 dbs in two different geographical locations. Any ideas (A-Z step by step) on how to implement this? I dont know much about database administration but I am willing to learn.
Thanks in advance
|
|
|
|
|
Well... let's start with what type of databases? SQLServer, etc.
Second, how 'real time' do you want the replication to be? Immediate? Seconds? Minutes?
Tim
|
|
|
|
|
Hi Tim,
Thanks for the reply.
Im looking at sql server 2005 db.
we are still deciding whether it should be immediate or 2 minute intervals
lets go with worst case - immediate - for now
|
|
|
|
|
i was trying to add the column names in the existing table using the stored procedure in sql server 2000.
My stored procedure is
CREATE PROCEDURE [dbo].[spInsert_Master] <br />
<br />
AS<br />
declare @les varchar(1000)<br />
<br />
delete tblmaster<br />
create table tblMaster(categoryname varchar(100) , casestudy varchar(100) , UnitInformation varchar(100) , locationname varchar(100)) <br />
declare les cursor for select lessonname from tblLessonMaster<br />
open les<br />
fetch next from les into @les<br />
while(@@fetch_status =0)<br />
begin<br />
fetch next from les into @les<br />
alter table tblMaster add @less varchar(500);<br />
select @les as lessonname<br />
end<br />
close les<br />
deallocate les
I got the error in the following line
alter table tblMaster add @less varchar(500);
says error near @less
i think i can't add the @ expression in the column name.
any idea for the alternative ?
I want to add the column names in the existing table using stored procedure.
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
try replacing this line
alter table tblMaster add @less varchar(500);
with
SET @Str = 'alter table tblMaster add ' + @less ' varchar(500);'<br />
Exec (@Str)
also need to declare @Str variable at the begining
Regards
KP
|
|
|
|
|
how can i check duplicate column names exist or not in the table?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
in SQL 2000 syscolumns contains all column names of each table and sysobjects contains all table names
Value 'U' in the column sysobjects.xtype indicates the objects is user table
id column in both tables are common which to be used for joining the two tables.
Regards
KP
|
|
|
|