|
Ah welcome to the correct forum. Your question however is still very obscure.
What do you mean by upload? Are you trying to deploy the database to s server, restore a backup, connect to an existing database what!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a column called bookedhalls, the value will be stored as Balaji-A,Balaji-C, i written select query as follows
Select * from function where bookedhalls like '%Balaji-A,Balaji-C,%
by using this i will get the row.
Suppose if i give '%Balaji-C,Balaji-A,%' i cannot get the row. How to get that row by using
Balaji-C,Balaji-A. Anybody knows please reply.
modified on Friday, September 24, 2010 6:17 AM
|
|
|
|
|
Your data model is fundamentally wrong, you should almost never be storing multiple values in one column with some delimiter (such as a comma). This is especially true if you need to query based on one of those multiple values.
bookedhalls should be a separate table, referenced to the rest of that row using foreign key relationships, this would allow you to select based upon this join.
|
|
|
|
|
Actually i created table caolled function in that fun_start_date and fun_end_date and booked_halls collms is there. Suppose u conside one date it is booked for 2 floors (balaji-A, Balaji-B). User will select in forms.
so i can write like select * from function where fun_start_date = 'date' and fun_end_date = 'date' and booked_halls like '%BALAJI-A,BALAJI-B,%'
i will get the row. If there is no row means he can go for inserting. Here is Ok.
Suppose user if select like first Balaji_B then Balaji-A in coding i will get string as a BALAJI-B,BALAJI-A.
if i write like select * from function where fun_start_date = 'date' and fun_end_date = 'date' and booked_halls like '%BALAJI-B,BALAJI-A,%' i will not get the row . I should get that row. So nobody should not book for that floor. How to do this.
|
|
|
|
|
Did you actually read my response above? By fixing your data model, it fixes this issue.
|
|
|
|
|
As pointed out already, your table structure is not a good one, that is why you are finding it tricky to write this query. You should read up about database normalization.
If you are really stuck with this data structure and cannot change it then you will need to do something like:
select * from function where booked_halls like '%BALAJI_A%' and booked_halls like '%BALAJI_B%'
But really you should change the data model because what you have at the moment is wrong.
|
|
|
|
|
Do NOT ignore the advice you have been given. Just because David has given you a work around FIX YOUR DATA STRUCTURE. If you do not do this NOW you will be back here continiously asking how to get at your data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am facing an issue in Insert Trigger.
I have 2 tables. Whenever I insert into Table 1, I have written a trigger to insert into Table 2. There is a stored procedure to insert in to Table 1 and there is an After Insert Trigger to insert into Table 2. The table 2 has one primary key and one foreign key.
When there is a Primary Key constraint violation (Or Unique Key), I am able to catch the error in the stored procedure and I am able to display the same to the user.
But if there is a foreign key constraint violation, I am not able to catch the error "Foreign Key Violation". Instead I am getting an error called "UnCommittable transaction".
Is there any way to catch this Foreign Key Violation error and display it to the user?
Note: I have a "Try... Catch" block in the stored procedure. But I don't have it in the Insert Trigger.
Thanks and Regards,
Peri
modified on Friday, September 24, 2010 5:31 AM
|
|
|
|
|
I have an application which has two database connections with two different logical databases (with different DSNs). Can I work with the sane SQL_HANDLE_ENV for both the connections, or do I need to create a new SQL_HANDLE_ENV for every logical database? Please help me.
|
|
|
|
|
Hi all im using SqlServer2005.. I need to insert multiple rows into a existing table(db1) from other database(db2).. There are around 400 rows(15 columns) need to be inserted. Both db are having same tables. how can i do it..
Thanks...
modified on Wednesday, September 22, 2010 5:34 AM
|
|
|
|
|
Which database?
test-09 wrote: other database(db2)
Database/table?
|
|
|
|
|
|
insert into table1 (columname1,columnname2) <br />
select columnmae1,columname2 from databasename.dbo.table2
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
For all 400 rows i need to write the statements?? or any other way..
test09
|
|
|
|
|
That is basic query with which you can import records between tables but in select query it depends on your criterias.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
I am having the same db with 2 back ups both have different information(table rows) i need to append both..
test09
|
|
|
|
|
Did you try that query?
I think you are trying to merge two databases into one, right?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
yes but i need to merge only one table..
test09
|
|
|
|
|
Then use my query and all will be done.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
using that query can insert single row how do i select all 400 rows.. or else i need to execute that query for each and every row..
test09
|
|
|
|
|
That query will insert all rows from table, not only one!
Better check this http://en.wikipedia.org/wiki/Insert_(SQL)
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
He's in trouble if he is trying to merge 2 tables, there will be duplicates unless he filters them out.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I warned him/her too in previos post, thanks for claryfing me
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Actually I think I could have left it a he's in trouble
His level of understanding about database needs upgrading
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Take the boys query and add a where clause that filters out existing records so you do not get duplicates. You need to identify the primary key (unique data) in both fields that can be used to apply the filter.
Never underestimate the power of human stupidity
RAH
|
|
|
|