|
|
Hello Friends
I have two table name Commitment & CommitmentDetail. There is a field name IsRejected in Commitment Table and another name Remarks in CommitmentDetail Table. Now I need to write a query that will select or print Remarks only if the value of IsRejected is 3. Otherwise it will not.
Any Help will be appreciated.
Ahanking in Advance
Johnny
|
|
|
|
|
If your logic is the same as in previous question, the query could be like:
SELECT
Remarks =
CASE (c.IsRejected = 1) THEN cd.Remarks
ELSE null
END,
FROM Commitment c
LEFT OUTER JOIN
CommitmentDetail cd
ON c.??? = cd.???
I didn't know what is the correct joining field, but you can fill that in.
|
|
|
|
|
|
|
how can i search text from table column ..
i am using SQL server 2005
|
|
|
|
|
amit sahu20 wrote: how can i search text from table column ..
You can use LIKE[^] operator.
|
|
|
|
|
I Think that is what is covered in any SQL Book. And its the First chapters of the Book. If you did not buy one buy it now.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/SQL7/2000/2005/2008
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@its.co.za
|
|
|
|
|
string cmd;
string field;
string parameter;
field = "Site,Model";
parameter = "@Site,@Model";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Database.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
sCommand.Connection = aConnection;
aConnection.Open();
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = CommunicationSettings.site;
sCommand.Parameters["@Model"].Value = CommunicationSettings.Select.ToString();
sCommand.ExecuteNonQuery();
aConnection.Close();
THat's my code, then i either get error:" Parameter @Model has no default value " or Data type mismatch ?
Thanks
|
|
|
|
|
Use debugger and see what is the value of sCommand.Parameters["@Model"].Value after the assignment.
|
|
|
|
|
it's a string value, i really can not understand why there is a type- mismatch
|
|
|
|
|
I can think of two possibilites. Either the value for the string is NULL or then the value is System.DBNull, but the column is defined as NOT NULL in the database.
|
|
|
|
|
Oledb does not support named parameters like SQL server does.
Your insert staement needs to use the question mark charcter (?) to indicate where a parameter should be substituted - it should expand to this:
"Insert into Run(Site, Model) values( ?, ?)";
The name provided for the parameter is basically irrelevant, only the order they are added to the parameters collection matters. The name can be used as a key ( as you are doing), to modify the OledbParameter properties after adding it to the collection, but it has no meaning in the insert sql statement itself; there you must use the '?' tokens to indicate a parameter.
You have asked this question before[^], and I gave you the same (correct) answer. Why are you still asking this?
|
|
|
|
|
Hello,
I build a report that connect to access file with oledb provider and manage to see a preview of the report in the visual studio development environment.
But in the report server I get error massage: "An error has occurred during report processing.
An attempt has been made to use a data extension 'OLEDB' that is not registered for this report server" when I try to view the report.
(I think it has to do with security because it works fine in the visual studio development environment).
How can I solve this problem?
Thanks in advanced, yaron.
|
|
|
|
|
|
What sql data field is the most suitable to store file navigation url?
comment:my data base is on MS-SQL server 2000.
thanks.
|
|
|
|
|
tomertro wrote: What sql data field is the most suitable to store file navigation url?
Since the url is a string, nvarchar would be a natural choice.
|
|
|
|
|
thanks.
what size do you recommand?
|
|
|
|
|
tomertro wrote: what size do you recommand?
Why limit the size? Define it as long as possible (was it 4000 in SQL Server 200?). If you want you can define a trigger to enforce logic on the column, but I don't see any reason to make limitation on column definition.
|
|
|
|
|
Can a url have unicode characters in it?
I avoid nvarchar like the plague and will only use varchar/char/text unless there is a specific unicode requirement.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Can a url have unicode characters in it?
You're right, as far as I know it cannot not have unicode characters. Varchar could be a better option.
|
|
|
|
|
You can use nvarchar.
SQL server 2000 also supports user defined datatypes. So you can also make your own url datatype.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
I have to tables in SQL Server 2005....
01) EmployeeMaster (DeptId as FK)
02) DepartmentMaster
Now, I am writing a SQL Query which returns me the All Employee from the EmployeeMaster belogs to the "SQL" department.
I manage to write the query but I want result in different manner:
My original result from the SQL is as under:
Result from SQL
--------------------
DeptId DeptCode DeptName EmpId EmpName
D00001 MS00001 SQL E00001 ABC
D00001 MS00001 SQL E00002 EFG
D00001 MS00001 SQL E00003 XYZ
My requirement is
---------------------
DeptId DeptCode DeptName EmpId EmpName
D00001 MS00001 SQL E00001 ABC
E00002 EFG
E00003 XYZ
in my requirement only one row will be displayed.
How can achieve this result by writting SQL Query?
Thanks,
|
|
|
|
|
Chadamama wrote: Result from SQL
--------------------
DeptId DeptCode DeptName EmpId EmpName
D00001 MS00001 SQL E00001 ABC
D00001 MS00001 SQL E00002 EFG
D00001 MS00001 SQL E00003 XYZ
My requirement is
---------------------
DeptId DeptCode DeptName EmpId EmpName
D00001 MS00001 SQL E00001 ABC
E00002 EFG
E00003 XYZ
in my requirement only one row will be displayed.
You have three rows in the data example. Do you mean that you don't want to show repeating values. If that's the case, as far as I know, you can't do it with SQL. You could write a procedure and manipulate the result in the proc.
|
|
|
|
|
Thank you very much!!!
I will try to do in function or Procedure.
your help is precious..
again thank you.
|
|
|
|