|
hi anyone give query to select first 4 records , select last 4 records , select next 4 records and select previous 4 records in MSSqlServer
|
|
|
|
|
More info needed: your result recordset must be ordered by something?
Check this " Row_Number() over"
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Hi all,
I have to select some data from a table where customer_name is not equal to John .
i used :
select data from table where customer_name != 'john'
select data from table where customer_name <> 'john'
bud it doe's not work. can somebody give me a good query?
thanx
modified on Monday, February 11, 2008 1:56 PM
|
|
|
|
|
You need quotes around john:
select column1,column2 etc
from table
where customer_name != 'john'
Assuming SQL Server you will need single quotes normally
Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
Ok, I sort of assumed you were using SQL Server and customer_name was a standard varchar column, in which case the != syntax will work fine. I have to say, its difficult to give good answers to poorly defined questions.
1. What type of RDBMS are you using? SQL Server? What version?
2. Please post your table definition.
If the customer_name is a char rather than a varchar there will be trailing spaces to pad to the length of the field, eg if customer_name is char(5) then your query should read != 'john '
While NOT LIKE '%john%' as suggested by Krish -KP should work it will not use any indexes on the customer_name column so there could be performance issues.
If you can supply this info then someone will be able to answer your question, but a good alternative is to try reading the the help, thats why it was written
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Check this ....
<br />
SELECT data FROM table WHERE customer_name NOT LIKE '%john%' <br />
hope your customer_name column is of Char datatype or contain john along with some more characters
Regards
KP
|
|
|
|
|
Obviously not that important then as you have not responded to my questions in an attempt to help you.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
again I am sending the same problem but this time I searched in google for the code,and use the code that I got from this forum
what I have found i am sending,
---------------------------------------
CrystalReport1 report=new CrystalReport1();
report.ReportOptions.EnableSaveDataWithReport = false;
CrystalDecisions.Shared.TableLogOnInfo myLogin;
CrystalDecisions.Shared.ConnectionInfo oCRConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in report.Database.Tables)
{
myLogin = myTable.LogOnInfo ;
//myLogin.ConnectionInfo.ServerName="(local)";
myLogin.ConnectionInfo.ServerName=".";
myLogin.ConnectionInfo.UserID = "sa" ;
myLogin.ConnectionInfo.Password = "123456" ;
myLogin.ConnectionInfo.DatabaseName="temp";
myTable.ApplyLogOnInfo(myLogin) ;
myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1);
}
OleDbConnection oleConn = new OleDbConnection("Provider=sqloledb; data source = .; initial catalog = inventory; user id = sa; password = 123456");
oleConn.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select * from student",oleConn);
DataSet ds=new DataSet();
da.Fill(ds);
CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
myReportDocument.Load(@"C:\Inetpub\wwwroot\temp\CrystalReport1.rpt",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy);
myReportDocument.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource =myReportDocument;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.DisplayToolbar = true;
CrystalReportViewer1.DisplayGroupTree = false;
oleConn.Close();
I did not got any error but my crystal Report Viewer contains no data i.e. it contains only Crystal Report Toolbar ,no data(Blank Report)
If I use F11 to run step by step ,I found the execution did not enter in the following Code.
foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in report.Database.Tables)
{
myLogin = myTable.LogOnInfo ;
//myLogin.ConnectionInfo.ServerName="(local)";
myLogin.ConnectionInfo.ServerName=".";
myLogin.ConnectionInfo.UserID = "sa" ;
myLogin.ConnectionInfo.Password = "123456" ;
myLogin.ConnectionInfo.DatabaseName="temp";
myTable.ApplyLogOnInfo(myLogin) ;
myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1);
}
What urgent modifications I need to perform?
Help me.
I am using .Net version 2003.
|
|
|
|
|
this problem already this in this forum,but my problem still be there,I googled the following code, and try to run,but did not work.
---------------------------------------
CrystalReport1 report=new CrystalReport1();
CrystalDecisions.Shared.TableLogOnInfo myLogin;
foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in report.Database.Tables)
{
myLogin = myTable.LogOnInfo ;
myLogin.ConnectionInfo.Password = "123456" ;
myLogin.ConnectionInfo.UserID = "sa" ;
myTable.ApplyLogOnInfo(myLogin) ;
}
CrystalReportViewer1.ReportSource=Server.MapPath("CrystalReport1.rpt");
CrystalReportViewer1.DataBind();
CrystalReportViewer1.RefreshReport();
CrystalDecisions.Shared.DiskFileDestinationOptions diskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
report.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
report.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
diskOpts.DiskFileName =Server.MapPath("Output.pdf");
report.ExportOptions.DestinationOptions = diskOpts;
report.Export();
Response.AddHeader("Content-Disposition","attachment;filename=Output.pdf");
Response.ContentType = "application/pdf";
Response.WriteFile("C:\\Inetpub\\wwwroot\\temp\\"+ "Output.pdf");
Response.End();
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = false;
Download option is comming,when trying to open that pdf file after downloading or just trying to open.
Error Meassage is
......
"There is an error Opening this Document.The File is damaged and could not be Repaired."
---
NOTE::: In Crystal Report Viewer the data is showed.
How can I solve that.I am using .Net version 2003
|
|
|
|
|
hi all, i thought this was the right place to post this Question about access. i have a report that is Ouputed as snapshot file,and it designed in MS Access. and when i run the Report i get the report without line, and it supposed to have lines as i have Displayed in the images i have sent. how can i do the other one to have lines. links to my Screen shots here
http://www.vbforums.com/attachment.php?attachmentid=62181&d=1202730083[^]
http://www.vbforums.com/attachment.php?attachmentid=62182&d=1202730099[^]
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
|
|
|
|
|
Hi
does any1 know how to enable remote connection for sql server 2000?
thanks
|
|
|
|
|
Difference between VARCHAR(100) and NVARCHAR(100) type variables ?
Thanks
You get the best out of others when you give the best of yourself.
|
|
|
|
|
Just Google for 'nvarchar varchar'
|
|
|
|
|
thanks
You get the best out of others when you give the best of yourself.
|
|
|
|
|
This may sound a bit weird...
But I need to find the data that does not match between two tables.
I'm using MySql
Suggestions are welcome
Thanks in advance.
modified on Monday, February 11, 2008 1:41 AM
|
|
|
|
|
If you are using SQL 2005, use the EXCEPT operator to find differences between entities.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Sorry, forgot to mention...
I'm using MySql...
I tried using NOT IN but it returns empty...
|
|
|
|
|
What code have you tried?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Something like this...
Search from tableA where id NOT IN (search id that match between tableB and tableA)
|
|
|
|
|
Assuming that you are working with Sql Server, you may try
Select A.[ColumnName],B.[ColumnName2] from table1 A,table2 B
where A.[PKColumn] <> B.[FKColumn]
Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime.
Pradeep Joe
|
|
|
|
|
Hi,
Say I have the table below:
Tabl1
PKey ColA ColB ColC
1 a1 b1 c1
2 a1 b2 c2
3 a1 b3 c3
... a2 ...
...
... a3 ...
...
If I group by ColA with the select statement as follows:
SELECT<br />
ColA, MAX(ColB), <br />
FROM<br />
Tabl1<br />
GROUP BY<br />
ColA
If for example for a1 the MAX(ColB) is b2, THEN I would like to include ColC in the select statement such that for a1 the resulting row would be:
ColA ColB ColC
a1 b2 c2
What is the best way to do this?
TIA!
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
select b.*
from (
select ColA, Max(ColB) as MaxColB
from Tabl1
group by ColA
) as a
Tabl1 as b
on b.ColA = a.ColA
and b.ColB = a.ColB
order by b.ColA
|
|
|
|
|
Hi all
I have two DB tables and i want to transfare data from one to another table by some criteria
the first table originalMsg and the other on named as Accepted_nick_name
iwant to select all nick name msg from the originalMsg and insert them to the Accepted_nick_name table
originalMsg
-----------
hi all
Record :timo
its me
Record:Tiko
hi every body
Accepted_nick_name
------------------
Record:timo
Record:Tiko
i do this by this sql query
INSERT INTO Accepted_nick_name (Nickname)
select original_msg_txt from originalMsg where
origainal_msg.original_msg_txt like '%record%'
Thats great and its working but i want the result as
Accepted_nick_name
------------------
timo
Tiko
without the Record word
so how can i modify this word from the set of date to be as i show
plz help me & Thanks alot
Kisha
modified on Sunday, February 10, 2008 4:38 AM
|
|
|
|
|
Use the T-SQL REPLACE function to remove the literal string 'Record:' from your text.
Is it actually necessary to store the string 'Record:' in each record value? What purpose does it serve? It looks like your database design may be broken and could do with normalization.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|