Odd Issue With Bound Columns When Fetching Data.

Aug 9, 2007

I'm using ODBC 3.0 in code written in C.

I have an service that connects using a system DSN using the SQL Server 2000 driver. On my development system with SQL Server 2005 Express installed, the queries work fine. I prepare a statement and then bind the columns that will be in the result set. On my system, I get all the data as it should be but on a live system, I do not get the proper data for the last three rows. I don't get any error messages from the query or the column binding and there are also no extra information messages that I can retrieve.

The table is something like the following. The names are changed to protect the guilty.

CREATE TABLE DOWNLOAD
(
FIELD_1 NUMERIC( 6,0 ),
ID CHAR( 15),
FNAME( 30 ),
LNAME( 40 ),
CLIENT_ID NUMERIC( 9,0),
CLIENT_NAME CHAR( 50 ),
CODE NUMERIC( 4,0 ),
PHONE CHAR( 10 )
)
go


On my system, running the exact same binary code as the client machine, I get all of the data from all of the columns as it should be. The problem is when I run on a client's system, the CLIENT_NAME, CODE, and PHONE columns return null values even when there is data there. On my development system the SQL Server instance runs on the same machine. On the client's sytem I am connecting to a remote instance of SQL Server 2000 on another system on the network.

My quandry is what could be different between the two systems that is causing me the problems?

View 10 Replies


ADVERTISEMENT

Fetching Of Data

Apr 14, 2007

hi,

I would like to know that, I have three instances of the same database at three different servers and I am trying to fetch the data from the select query. "select * from table_name"



I would like to know, whether the order of rows fetched by this query will be different on different servers of sql server or the same order of rows will be fetched.



For me the output is coming different on each server database with he same query . Pls let me know, is there any default order by or it takes it randomly.



Thanks

Gaurav Gupta



View 1 Replies View Related

Data Fetching... The Right Way.

Oct 12, 2007

Hi,

I'm currently developing an application using C# and SQL Server Express, in which one of the functionalities is to allow the user to browse through the existing products, wether by browsing one by one (next, previous, first, last) or performing a search (by product name, id, etc.). I'm currently using the default DataSource and TableAdapter aproach, but I found out that when I execute the TableAdapter.Fill() method, all the data in the table is fetched... what with 10,000 records it takes a bit to perform, specially on slower connections.

So my doubt is, what would be the best aproach to solve this problem? I'm considering loading first position, and then when the user presses the next button I'd fetch second position, etc, this using ROW_NUMBER(). I could even cache every other 10 records or something like that. Since it is possible to know any records row number (as long as the records are ordered) it would even work when the user performs a search and goes directly into row number 5000 for instance.

Would this aproach be a good practice, because that's all I want, to do things the right way? Thank you for your time

EDIT: I've noticed that when creating a SqlDataReader there is the option to provide a CommandBehavior, but I'm not quite undestanding how this could be used, would some tweaking in this area do the job?

View 3 Replies View Related

Fetching Data From SQL Server

May 10, 2008

Hi,
 I have a small Problem.
Lets say i have 6 rows in a table (two column month and MonthCost )naming jan,feb,mar,apr,may.jun and all of them have some data. but while displaying in Ui i need to show all the months from Jan to december and july to december with values as something, say 0
so the values displayed in gridview sholud be like this
Month MontCost 
Jan          1
Feb         1
Mar         1
.
.
.
Jul          0
Dec        0
. I tried it can be done using a temp table in db , but think of a scenaio where the i want to display for Number of times( 1 to 12 * 50). I don't want to  hit performance and i am uisng sql server 2000.
 Any hints or suggestions are welcomed.

View 7 Replies View Related

Error In Fetching Data

Mar 15, 2006

hello i'm using visual studio 2005 and asp.net 2 i have an error in the code that fetching data from databse in grid here is the code :Dim con As SqlConnection        con = New SqlConnection("Data Source=local;AttachDbFilename='D:New Folderhorushorus.mdf';Integrated Security=True")        Dim cmd As New String("SELECT TOP (10) serial, name, gender, dateofbirth FROM(dbo.students)ORDER BY RAND(CONVERT(varbinary(4), NEWID()))")        Dim cd As SqlDataAdapter        cd = New SqlDataAdapter(cmd, con)        Dim ds As New DataSet()        cd.Fill(ds, "students")        grid.DataSource = ds.Tables("students").DefaultView        grid.DataBind()that code is selecting random records from the database and showing it in grid the error is in the cd.fill(ds,"students") line so can any one help me in that problem.thanks       

View 14 Replies View Related

Fetching Data In A Datatable

Apr 21, 2006

hello, i'm using asp.net 2 with VB, i have a table in my db named 'exams' and i have 6 columns in this table one for question number and one for the question and 3 columns for 3 answers and a last column for the right answer, now in my page i want to show 7 questions and  each  question has 3 answers that i can choose between them i want the question appear in datatable and the answers in radiolist i have a little code for that but it shows an error it says "no row at position 1" so hope u guys can help : Dim con As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|aspnetdb.mdf;Integrated Security=True;User Instance=True")        Dim a As New ArrayList(8)        Dim i As New Integer        i = 0        Dim d As New DataSet()        Dim cmd As New SqlDataAdapter("select top(7) question from exams", con)        cmd.Fill(d, "exams")        a.Add(d.Tables.Item(0, 1))        i = i + 1        Dim ta As New DataTable        ta.Rows(i).Item(0).text = d.Tables(0).Rows(0)(i)and by the way this code is for the questions i still dont have the code for the answers that will appear in a radiolist hope u can help .thanks

View 3 Replies View Related

I Am Getting Problem In Fetching Data Using C++

May 21, 2007

Hi All,

I am getting problem in fetching data from SQL using C++ program.
How to Fetch SQL Unicode characters?
I am using ODBC driver calls in C++ to fetch SQL data.
It is working fine with character data.
But for Unicode data it displays “????� instead of data.
Can anybody please help?

Regards
Ketaki

View 3 Replies View Related

Problem With Fetching Data

Mar 4, 2008

Hi i have 6 tables

1.location
id primary key
authorization string
count int
2.account
acc_id primary key
loc_id foreign key of location table
hsr string
3.Line
id primary key
intaralata string
interalat string
4.trunk
id primary key
intaralata string
interalat string
5.RCF
id primary key
intaralata string
interalat string
6.TSG
id primary key
intaralata string
interalat string

now i need to fetch the field authorization from location table by the following conditins

LOCATION.AUTHORIZATION using ACCOUNT.LOC_ID. If any (LINE/TRUNK/TSG/RCF.INTERLATA/INTRALATA= ’F’), and this value is blank, send LOCATION.AUTHORIZATION

can anyone help me out in this scenario. i need the sql query for fetching that fiels.

thanks in advanvce

View 3 Replies View Related

Problem In Fetching Data

Nov 21, 2007

Hi i am firing a query in SQL SERVER CE as given below


SELECT Ticker_Master.Ticker, Ticker_Master.Company_Name, Capital.DataSet_Date, Capital.Quick_Ratio, Dividend.Payout
FROM Ticker_Master INNER JOIN Capital ON Ticker_Master.Ticker = Capital.Ticker INNER JOIN Dividend ON Capital.Ticker = Dividend.Ticker AND Capital.DataSet_Date = Dividend.DataSet_Date AND Capital.Region = Dividend.Region
WHERE (Capital.Quick_Ratio = @PARAM1) AND (Capital.DataSet_Date BETWEEN @PARAM3 AND @PARAM4) AND (Capital.Region = @PARAM5) OR
(Capital.DataSet_Date BETWEEN @PARAM3 AND @PARAM4) AND (Capital.Region = @PARAM5) AND (Dividend.Payout = @PARAM2)


On execution is asks 4 the parameter values as follows :
@PARAM1
@PARAM3
@PARAM4
@PARAM5
@PARAM2

After values are given on execution it throws error as
Duplicated parameter names are not allowed. [Parameter Name = @PARAM3]

Can anybody tell me what's wrong ?????????????????

thanx in advance

View 4 Replies View Related

Error While Fetching Data From DB2

Oct 30, 2007

Hi,

I am getting an error while fetching data from IBM DB2:
I am using an OLE DB Connection provider - "IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider".

I am also setting the "Force Translate" value in "Data Link Properties" of the Connection to "37" because I am getting some BYTE_STREAM data which I need to translate.

I am using the OLE DB Source to extract data using a SQL Query. I can see the data correctly when I do a "Preview".

However, when I execute the task, I get the following error.
It will be great if someone can help me with this.

Error: 0xC0202009 at Customer Telephone, CUSTOMER_TELEPHONE Source [238]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E00.

Error: 0xC0047038 at Customer Telephone, DTS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "CUSTOMER_TELEPHONE Source" (238) returned error code 0xC0202009. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

Error: 0xC0047021 at Customer Telephone, DTS.Pipeline: SSIS Error Code DTS_E_THREADFAILED. Thread "SourceThread0" has exited with error code 0xC0047038. There may be error messages posted before this with more information on why the thread has exited.

Error: 0xC0047039 at Customer Telephone, DTS.Pipeline: SSIS Error Code DTS_E_THREADCANCELLED. Thread "WorkThread0" received a shutdown signal and is terminating. The user requested a shutdown, or an error in another thread is causing the pipeline to shutdown. There may be error messages posted before this with more information on why the thread was cancelled.

Error: 0xC0047021 at Customer Telephone, DTS.Pipeline: SSIS Error Code DTS_E_THREADFAILED. Thread "WorkThread0" has exited with error code 0xC0047039. There may be error messages posted before this with more information on why the thread has exited.



Thanks and Regards,
B@ns

View 3 Replies View Related

Fetching Data From A Web Service

Apr 25, 2007

Hello All,

I have to fetch data in an ssis package from a set of web services. what is the best way of doing this?

The web services are session based, this means that multiple calls are needed to complete one operation. like one to log on, second onwards to execute calls, and the last one to log out.

(there is some cookie management also required to logon successfully into the web services).

Should we write a custom task which will fetch the data for us? Or just write a C# component which is invoked from SSIS?

Regards,
Abhishek.

View 1 Replies View Related

Avoiding Index While Fetching Data

Mar 7, 2001

Hi there,
I'm using a query to fetch data from a table where one of the criteria is IN(...) clause for the key column of the table.Now the data being retrieved is ordered by the key column of the table even though I haven't specified any order by clause.
I want to know if there a way in which the data being fetched is in the order of my IN(...) clause.


Thanx
Aby

View 3 Replies View Related

Fetching Data From IBM DB2 To SQL Server 2005

Sep 26, 2007

Hi,

I am trying to fetch data from IBM DB2 to SQL Server 2005.
The problem I am facing is when I create the OLE DB Connection (I am using the "IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider") and see the "Preview", I get "System.Byte[]" in a couple of columns for all the rows, instead of the actual data.
The datatype of the original field is "Byte Stream".
I have tried all options, but, failed. I believe there is something in the "Force Translate" property of the OLE DB Connection. Right now it is set to "65535". I am not sure if that needs to be changed.

I was earlier using a DTS package, where I used ODBC for connecting to the same database. In ODBC, there is a "Translation" tab where there is a check box labelled: "Convert binary text (CCSID 65535) to text".
When I check this box, I am able to see the data correctly.

But, now I have moved to SSIS and I am facing the same problem as I am not using the ODBC connection.

Please help.

Thanks and Regards,
B@ns

View 5 Replies View Related

Fetching Case Sensitive Data From The Database

Apr 7, 2008

S/W Technologies : C#.Net 2005, ASP.Net 2005, SQL Server 2005
Greetings everyone,
       Heres my code for login verification, which is written in the login button click.
SqlCommand cmd = new SqlCommand("Select uid,pass from UserRegistration where uid='" + txtuname.Text + "' and pass='" + txtpass.Text + "'", con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.HasRows) {  <code......> }
     Now, my problem is, the SQL Server 2005 is fetching rows without checking case. For e.g. if I enter a password as "MYSTERY" or "mystery" which is stored as "Mystery" in the database. The datareader shows positive in HasRows property. So, Can someone suggest me how to fetch case sensitive data from SQL SERVER 2005. Thanks.

View 3 Replies View Related

SQL Server 2008 :: Data Fetching 80 Million Records?

Mar 24, 2015

i have table below

CREATE TABLE [dbo].[DR_Test](
[source_item_id] [int] NOT NULL,
[source_line_no] [int] NULL,
[buyer_id] [int] NOT NULL,
[seller_member_id] [int] NULL,

[code]...

the table contains more than 80 million records so when i fetch the data using buyer_id & timezone its taking lot of more than 1 hours or so....& where buyer_id is not unique.how to fetch the data fast or need to change the structure of the table

View 3 Replies View Related

SQL Server 2012 :: Fetching Large Data From Teradata?

Jun 9, 2015

I am fetching large amount of data from teradata to sql server using linked server. I am facing below query:

A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)

View 0 Replies View Related

Problem While Fetching Data From Oracle Linked Server

Mar 5, 2007

Hi,

I created a linked server as follows:

EXEC sp_addlinkedserver 'OracleLinkedServer', 'Oracle', 'MSDAORA', 'fcstage'

EXEC sp_addlinkedsrvlogin 'OracleLinkedServer', false, 'SA', 'fc_stage', 'password'

Now I try firing a simple select statement

SELECT FINANCIAL_TRX_INFO_ID FROM

[OracleLinkedServer]..[FC_STAGE].[WFS_FINANCIAL_TRX_INFO]

WHERE SFS_BUSINESS_SEGMENT IS NOT NULL

But I get the following error:

OLE DB provider "MSDAORA" for linked server "OracleLinkedServer" returned message "ORA-01426: numeric overflow

".

Msg 7330, Level 16, State 2, Line 1

Cannot fetch a row from OLE DB provider "MSDAORA" for linked server "OracleLinkedServer".

This seems to be a generic error statement. Can anyone tell me where am I going wrong.

Thanks.

View 1 Replies View Related

Formating Bound Data

Apr 27, 2006

How do I change, or add to, the following code so as to be able to format the display:

this.txtAppointmentDate.DataBindings.Add(new Binding ("Text", dsData.Tables["Results"],"AppointmentDate")

The data is stored in SQL Server as datetime and I want only the date portion to show in the TextBox.

Thanks in advance

View 1 Replies View Related

Timeout Expired Error Occuring While Fetching The Data With SQL Server 2000

Sep 12, 2005

Hello,I have one application which is having written in asp.net & plain asp.I am having one button on asp page,when i will click on that button, then itwill execute one other asp page.And after the execution of that second asp page, I redirect it to someASPX page with some values.On the ASPX page, it will connect to the Database, and insert the values.Thus, sometime, the following error is occuring :"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."Main thing is that i am testing it on my local machine, then also it is giving me this error ...Insert into statement is also not much complicated :just I inserted three values in one table.Is this occuring due to the mixer of asp & aspx??Plz give me some proper solution.I want it in efficient manner, because this application will be accessed by number of users at the same time.Plz help me.Thanks,Sandy

View 3 Replies View Related

Facing Problems With Data Bound Footer.

Feb 20, 2008

hi everybody..

I have placed a textbox in a page footer of SSRS which is linked with a
databound text box in the body of the report.. which i intended would
give the report databound footer...
but now the problem is tat they dont show up on every page..
earlier they use to mostly not show up at all
or show up on the first or the last page...

could some1 help.??

once i render it to pdf..
all the page footers cant be seen.

regards.

savio

View 4 Replies View Related

How Can You Place A Data Bound Footer In SSRS On Every Page?

Feb 18, 2008

I am having another setback with a report which has got multiple tables and sections.
Here i wanted to have a footer for every page which is databound to a table. now since there are multiple
sections and multiple tables...the things have become more complicated. is there any way you could tell
me to go around this problem so that i can put a common footer on every page of the reports no matter how many pages
it goes on??

Just to put it in points... I need.. to

a) Place a databound footer(a footer that is bound to a datasource and not hard coded) into the page footer in SSRS.
No matter how long the report is in pages.
b) I need it to appear on every page of the report after it is rendered to a PDF.
I have placed a textbox in the body of the report and linked it to a textbox in the footer of the report.
Now the thing is it is not working.
Cud u please tell me diffrent ways or any possible way this could be done.?

Plz help..
Regards
Savio

View 2 Replies View Related

Checkbox Data-bound To A Bit SQL Field Can't Handle NULL Values

Jun 18, 2004

I have a checkbox on my webform that is bound to a bit field in my SQL table. I'm fine as long as I've got the bit field set to 0 or 1, but if the field is NULL, the checkbox throws an exception during the databind.

Is there any way to handle this without removing the data binding and manually setting the value (ie: some way to intercept it before the exception gets thrown and then setting the field value in the dataset)?

Thanks!

View 1 Replies View Related

How To Get A Data Bound Page Footer In SSRS In A Report Having Multiple Tables?

Feb 19, 2008

hello to all..

can someone tell me how I counld get a pagefooter linked textbox to show a data bound
page footer in a report having 8 tables....???
I have tried the common solution showed on the previous forums..
They worked when there was only one table...
where in i could place a group in 1 of the cells in the table body of the report.
but now since der are 8 tables in the report.. d job is become very tricky.

the page footer is not showing up on all the pages of the report.
it only shows on the first page of the report.

Plz help......

Regards
Savio.

View 1 Replies View Related

Transact SQL :: Select And Parse Json Data From 2 Columns Into Multiple Columns In A Table?

Apr 29, 2015

I have a business need to create a report by query data from a MS SQL 2008 database and display the result to the users on a web page. The report initially has 6 columns of data and 2 out of 6 have JSON data so the users request to have those 2 JSON columns parse into 15 additional columns (first JSON column has 8 key/value pairs and the second JSON column has 7 key/value pairs). Here what I have done so far:

I found a table value function (fnSplitJson2) from this link [URL]. Using this function I can parse a column of JSON data into a table. So when I use the function above against the first column (with JSON data) in my query (with CROSS APPLY) I got the right data back the but I got 8 additional rows of each of the row in my table. The reason for this side effect is because the function returned a table of 8 row (8 key/value pairs) for each json string data that it parsed.

1. First question: How do I modify my current query (see below) so that for each row in my table i got back one row with 19 columns.

SELECT A.ITEM1,A.ITEM2,A.ITEM3,A.ITEM4, B.*
FROM PRODUCT A
CROSS APPLY fnSplitJson2(A.ITEM5,NULL) B

If updated my query (see below) and call the function twice within the CROSS APPLY clause I got this error: "The multi-part identifier "A.ITEM6" could be be bound.

2. My second question: How to i get around this error?

SELECT A.ITEM1,A.ITEM2,A.ITEM3,A.ITEM4, B.*, C.*
FROM PRODUCT A
CROSS APPLY fnSplitJson2(A.ITEM5,NULL) B,  fnSplitJson2(A.ITEM6,NULL) C

I am using Microsoft SQL Server 2008 R2 version. Windows 7 desktop.

View 14 Replies View Related

A Word About Meta-data, Pass Through Columns And Derived Columns

Oct 13, 2006

Here's another one of my bitchfest about stuff which annoy the *** out of me in SSIS (and no such problems in DTS):

Do you ever wonder how easy it was to set up text file to db transform in DTS - I had no problems at all. In SSIS - 1 spent half a day trying to figure out how to get proper column data types for text file - OF Course MS was brilliant enough to add "Suggest Types" feature to text file connection manager - BUT guess what - it sample ONLY 1000 rows - so I tried to change that number to 50000 and clicked ok - BUT ms changed it to 1000 without me noticing it - SO NO WONDER later on some of datatypes did not match. And boy what a fun it is to change the source columns after you have created a few transforms.

This s**hit just breaks... So a word about Derived Columns - pretty useful feature heh? ITs not f***ing useful if it DELETES SOME of the Code itself after there have been changes in dataflow. I cant say how pissed off im about that SSIS went ahead and deleted columns from flow & messed up derived columns just because the lineageIDs dont match.

Meta-data - it would be useful if you could change it and refresh it - im just sick and tired of it that it shows warnings and errors when there's nothing wrong - so after a change i need to doubleclick all my transforms so that those red & yellow boxes would disappear.

Oh and y I passionately dislike Derived columns - so you create new fields based on some data - you do some stuff - combine multiple columns to one, but you have no way saying remove the columns from the pipeline. Y you need it - well if you have 50K + rows with 30+ columns then its EXTRA useless memory overhead for your package.

Hopefully one day I will understand how SSIS works (not an ez task I say) - I might be able to spend more time on development and less time on my bitchfest - UNTIL then --> Another Day - Another Hassle with SSIS

View 5 Replies View Related

Nested Fetching

May 21, 2008

Hi all!I'm trying to write a T-SQL statement that will allow me to do a maintenance for all user table for all databases on my server.This is what I got so far :DECLARE @cStatement varchar(255)DECLARE @dStatement varchar(255)DECLARE T_database CURSOR FOR SELECT '[' + CONVERT(varchar(64),name) + ']' FROM master.dbo.sysdatabases WHERE dbid>6SET nocount ONOPEN T_databaseFETCH NEXT FROM T_database INTO @dStatement WHILE (@@FETCH_STATUS <> -1)begin-- LOOP IMBRIQUÉ POUR PASSER AU TRAVERS DE CHAQUES ELEMENTS-- DE LA BASE DE DONNÉES ACTUELLE.EXEC ('DECLARE T_cursor CURSOR FOR SELECT ''UPDATE STATISTICS ['' + CONVERT(varchar(64),name) + '']'' FROM ' + @dStatement + '.dbo.sysobjects WHERE type = ''U''')OPEN T_cursorFETCH NEXT FROM T_curosr INTO @cStatementWHILE (@@FETCH_STATUS <> -1)beginPRINT(@cStatement)FETCH NEXT FROM T_cursor INTO @cStatementendDEALLOCATE T_cursorFETCH NEXT FROM T_database INTO @dStatement endDEALLOCATE T_databaseBut I get a sh**t load of errors :Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Msg 16916, Level 16, State 1, Line 15A cursor with the name 'T_curosr' does not exist.Please help!!! :beer:

View 14 Replies View Related

Fetching An Id To Use In Another Task

Jan 24, 2007

Hi there,

i have a task that has a ole-db destination. it inserts some data to a table. it's always 1 record that is gonna be inserted.after that the task is finished. however i want to use that same record in the followup-task. is there a way to retrieve the id of that specific record.

Please note that the id of the record is an int-identity from sql-server itself.

at the moment i'm fiddling with "remembering" the inserted data and hopefully it will be a 100%match in the next task, but i have a dark feeling it's not 100%.

is there a common way how to approach this?

View 1 Replies View Related

SQL_NO_DATA When Fetching

May 6, 2008

Hi all,

While I was testing our application installation on Vista, I ran across this problem:

When a program on Vista is executing a SPROC is a SQL Server on Vista (actually same machine), the SQLFetch(m_hstmt) returns a SQL_NO_DATA.

When the exact same program is executed on XP SP2 client against the same Vista based SQL Server, it correctly returns the rows.

The build of the program was done on a MDAC 2.8 XP SP2. When I tried to install 2.8 on Vista machine it seemed to have failed.

Using DSN vs. DSNless connection string made no difference. Nothing of intest in SQL Logs either.

Any clues?

View 3 Replies View Related

Fetching Continuous Dates

Jun 20, 2008

hai,

set dateformat dmycreate table tbl_sampemptable(employeeid int,StartDate datetime)
declare @employeeid intset @employeeid=1declare @startdate datetime,@enddate datetimewhile(@employeeid<=1000)begin set @startdate='01/05/2008' set @enddate='31/05/2008' while(@startdate<=@enddate) begin      if(@employeeid<>1 and @startdate<>'02/05/2008')      insert into tbl_sampemptable values (@employeeid,@startdate)             else if(@employeeid=1)      insert into tbl_sampemptable values (@employeeid,@startdate)z      set @startdate=dateadd(day,1,@startdate)
 endset @employeeid=@employeeid+1end
select * from tbl_sampemptabledrop table tbl_sampemptableset dateformat mdy
 
 
i have to select records depending on @count parameter to this table.Depending on this parameter value it should fetch sequential dates.For example
if @count=2then result should be like this,
 
EmployeeID                 FromDate                 ToDate
1                                 01/05/2008               02/05/2008 
1                                 03/05/2008               04/05/2008
.
.
2                                 03/05/2008               04/05/2008 //note that here 01/05/2008 is  not  selected
                                                                                     because 02/05/2008 is missing
2                                 05/05/2008               06/05/2008
.
.
3                                03/05/2008               04/05/2008 //note that here 01/05/2008 is  not  selected
                                                                                     because 02/05/2008 is missing
3                                05/05/2008               06/05/2008
.
.
 
if @count=3 then result should be like this,
 
EmployeeID                 FromDate                 ToDate
1                                 01/05/2008               03/05/2008 
1                                 04/05/2008               06/05/2008
.
.
2                                 03/05/2008               05/05/2008 //note that here 01/05/2008 is  not  selected
                                                                                     because 02/05/2008 is missing
2                                 06/05/2008               08/05/2008
.
.
3                                03/05/2008               05/05/2008 //note that here 01/05/2008 is  not  selected
                                                                                     because 02/05/2008 is missing
3                                06/05/2008               08/05/2008
.
. how can i do this.please help me.thanks in advance

View 8 Replies View Related

Fetching Record From Table

Sep 17, 2007

Hi,
I am facing a peculier problem. I have 3 records in my table. when i am trying to fetch the top 2 its able to fetch the records. but when trying fro moire than 2 (say top 3 or just the *) it say time out. can any one help me out in this regard.


Below is the error that I get when tryong to open the record from SSMS

SQL Execution Error.

Executed SQL statement: SELECT Transaction_ID, tril_gid, WorkGroup_ID, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate, LCID FROM Symp_TransactionHeader
Error Source: .Net SqlClient Data Provider
Error Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---------------------------
OK Help
---------------------------


Thanks,
Rahul Jha

View 2 Replies View Related

Fetching Duplicate Rows

Jan 14, 2004

Hi,

I have some duplicate rows in a table. I didnt define any primary key or unique key on the table.

I can get unique rows using DISTINCT, but i want to fetch only the duplicated rows and also i want to delete the duplicated rows.

How can i do it?

Please help me.....

Thanx in Advance

View 4 Replies View Related

Fetching Unique Pins...

Feb 14, 2006

Hi,I have a table which contains a bunch of prepaid PINs. What is thebest way to fetch a unique pin from the table in a high-trafficenvironment with lots of concurrent requests?For example, my PINs table might look like this and contain thousandsof records:ID PIN ACQUIRED_BYDATE_ACQUIRED....100 1864678198101 7862517189102 6356178381....10 users request a pin at the same time. What is the easiest/best wayto ensure that the 10 users will get 10 different unacquired pins?Thanks for any help...

View 14 Replies View Related

Fetching Information For All Views

May 21, 2008

I want to fetch definitions for all stored procedures & views in a database.
For stored procedures, I use sp_stored_procedures to retrieve all SPs & then use Procedure_Name column to fetch each SP's name followed by a call to OBJECT_DEFINITION to retrive its definition.

Now, I have found 'sp_views_rowset2' that returns all views. As I am not very sure about it, this is just for confirming that the task of 'sp_views_rowset2' is actually to return all views defined for the database!!!

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved