|
Hi all,
Please help me with the below sql query
I am having 4 tables
SML,SMG,SMS,TKM
I have to retrive records
2 columns from table SML
1 columns from table SMS(the mapping from table SML and SMS is through SMG for eg: using the foreignid of SMG in SML we get the foreignid of SMS in the table SMG, using this i have to get the column from the table SMS)
1 column from table TKM (the mapping is SMS and TKM directly using the foreignid of TKM in the table SML)
Table SML:
ID Name idSMG IDTKM
Table SMG
ID idSMS
Table SMS
ID Name
Table TKM
ID Name
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
What have you come up with so far?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,I am new comer of sql server2005.How can I know the database version through query.Pls help me
|
|
|
|
|
SELECT @@VERSION
Next time i will not give you an Answer, you must First Google before you post here on the Forum.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I know this query.By this I know the version of sql server.Can I know the version of master database or user create database version.
|
|
|
|
|
hi I dont Understand what you want.
Forum: SQL and Database discussions
Subject: Re: Know the Database version
Sender: Sritanu _ Ghosh
Date: Friday, August 1, 2008 2:46 PM
Does a Database have a Version ?
Am not sure what you want. ok
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswa Maseko wrote: Does a Database have a Version ?
I think he wanted to ask the compatibility level(SQL 7.0/2000/2005 etc).
Here's the GUI process:
In the management studio, right click on the db -> select Properties -> click on Options -> the Compatibility Level is displayed along with the collation and recovery model.
But I dont know how to retrieve it using T-SQL.
Syed Mehroz Alam.
|
|
|
|
|
i was Suprised , lets hear if this solves his Problem.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Is this what you are looking for ?
SELECT name, compatibility_level FROM sys.databases
Please... SAVE my time by rating the posts that you read!
There are 10 kinds of people in the world: those who understand binary and those who don't.
|
|
|
|
|
Please help...
Is there a way when I use initcap to make any letters displayed after an apostrophe be lowercase?
thanks in advance!
|
|
|
|
|
Please i need help...
Can somebody explain me how can i implement an insertion trigger that inserts in another table.
Like i have one table wich i want to insert a new record but when i insert a record in the first table the same record must be inserted in an another table for security...
By the way im using sql server 2000 in this project.
Thanks
Sorry about the english, i speack portuguese ....
Just learning
|
|
|
|
|
Hi,
You would need something like this:
CREATE TRIGGER Duplicate ON TableName
AFTER INSERT AS
INSERT INTO AnotherTable (Column1, Column2...) SELECT Column1, Column2... FROM inserted
END
Mika
|
|
|
|
|
Oi,
Eu já fiz algumas bases de dados e nunca precisei á data, de usar triggers (em sql).
Mas queres inserir dados ao mesmo tempo em duas tabelas? Porque não fazes isso com uma store procedure normal, achas que não dá para isso?!
O que tens na ideia? talvez te possa ajudar.
|
|
|
|
|
|
We need to know what the data looks like in your file and exactly what you want when you are done with your query. It sounds like you do not have much experience with SQL so I'd suggest taking a look at some of these sites to get some basic knowledge:
SQL Tutorial[^]
SQL.org[^]
Another Tutorial[^]
Google list[^]
|
|
|
|
|
I'm having some issues with a Query I'm trying to use to fine similar records in a master table. There are several child tables that will be searched in a similar way. Basically, if there are more than two matches in the sub query I want to display those records.
Can anyone point me in the right direction to get this query to work? I understand why I can't use more than one field in my subquery but I can't think of another way to do this.
SELECT *
FROM UC
WHERE uc_key IN (SELECT mo_Key, COUNT(mo_key) as KeyCount
FROM MO
WHERE (mo_MoKey = @Key1 AND mo_Value = @Value1) OR (mo_MoKey = @Key2 AND mo_Value = @Value2) <- there will be a variable number of these that get generated programatically
AND KeyCount > 2)
(note, the table names have been mangled to protect the innocent)
Thanks, any ideas are appreciated.
|
|
|
|
|
You probably still want a JOIN; avoid using IN for anything other than literal lists.
|
|
|
|
|
Using a JOIN will improve speed?
|
|
|
|
|
It has in my experience. And much more flexible.
|
|
|
|
|
I'll have to experiment in that direction then. This is a nasty complicated app and I'll need all the little speed boosts I can get.
Thanks!
|
|
|
|
|
I can imagine. Your first task should be to eliminate the subqueries; they don't benefit from indices.
I had to change some of my JOINs the other day because the statements seemed to just sit there, now they zip along.
|
|
|
|
|
Hi,
Didn't test this so there may be typos but try something like this:
SELECT *
FROM UC
WHERE uc_key IN (SELECT mo_Key
FROM MO
WHERE (mo_MoKey = @Key1 AND mo_Value = @Value1)
OR (mo_MoKey = @Key2 AND mo_Value = @Value2)
GROUP BY mo_Key
HAVING COUNT(*) > 2);
Hope this helps,
Mika
|
|
|
|
|
Excellent, thank you for your help!
One thousand internet dollars are coming your way, just put your ethernet cable into the trash can can to catch it all.
|
|
|
|
|
|
If I understand you correctly, you just need a simple inner join.
Select ...
From YourPrimaryTable
InnerJoin YourDetailTable
on YourPrimaryTable.Column1 = YourDetailTable.Column1
and YourPrimaryTable.Column2 = YourDetailTable.Column2
...
Hope that helps.
Syed Mehroz Alam
|
|
|
|