Selecting Data

Aug 21, 2001

Hello .
Sometimes when i try to select data from a table (from a selected database)
using SQL Query Analyzer (for exemple) i receive an error message : "The Object XX does not exist" . But when i prefix it by the Owner it work .

What is the problem then ?

View 1 Replies


ADVERTISEMENT

Selecting A Single Data Source From Multiple Data Sources

Aug 4, 2006

Hi,

I am pretty new to SSIS. I am trying to create a package which can accept data in any of several formats. i.e. CSV, Excel, a SQL Server database/table and import the data into my destination database.

So far i've managed to get this working OK. However I am now TOTALLY stuck. I'm currently trying to just concentrate on the data sources being a CSV (using a Flat File Data Source) and/or an Excel Spreadsheet.

I can get the data in and to my destination using a UNION ALL component and mapping the data sources to it so long as both the CSV file and the Excel spreadsheet exist.

My problem is that I need my package to handle the possibility that only the CSV file might exist and there is no Excel spreadsheet. In which case i'd like the package to ignore the Excel datasource completely. Currently either of my data sources do not exist I get errors and the package terminates.

Is there any way in SSIS that I can check all my data sources to see which ones exist (i.e. are valid). If they exist I want to use them. If it doesn't exist i'd like to disgard it (without error - as long as there is a single datasource the package should run)

I've tried using the AcquireConnection method in a script task on each of my connections, hoping that it would error if the file/datasource did not exist. It doesn't though (in the case of an Excel datasource it just creates a empty excel file for me).

The only other option I can come up with are to have seperate packages depending on the type of data we want to import and then run a particular package depending on the format of the source data. This seems a bit long winded. I am pretty sure I must be able to do what I want to achieve but I can't work out how.

I'll be grateful to anyone who can send me any tips/hints/links on how I can achieve this.

Many thanks

Rob Gibson

View 5 Replies View Related

Data Access :: Selecting Data Without Making Any Lock

Oct 26, 2015

I have a scenarios where if I execute select * from tbl it should display the all the records without waiting to release any lock.  For example suppose I have one table called tbl and one session is updating one records and not committed yet and in other session if i execute select * from table I can see all the records, for that records it can show me older version. but my select statement should not wait to commit another session and also it should not show the modified data.

View 4 Replies View Related

Selecting The Most Recently Edited Item AND Selecting A Certain Type If Another Doesn't Exist

Sep 20, 2007

I've got a big problem that I'm trying to figure out:
I have an address table out-of-which I am trying to select mailing addresses for companies UNLESS a mailing address doesn't exist; then I want to select the physical addresses for that company. If I get multiple mailing or physical addresses returned I only want the most recently edited out of those.

I don't need this for an individual ID select, I need it applied to every record from the table.

My address table has some columns that look like:
[AddressID] [int]
[LocationID] [int]

[Type] [nvarchar](10)
[Address] [varchar](50)
[City] [varchar](50)
[State] [char](2)
[Zip] [varchar](5)
[AddDate] [datetime]
[EditDate] [datetime]

AddressID is a primary-key non-null column to the address table and the LocationID is a foreign key value from a seperate Companies table.
So there will be multiple addresses to one LocationID, but each address will have it's own AddressID.

How can I do this efficiently with perfomance in mind???

Thank you in advance for any and all replies...

View 2 Replies View Related

Selecting Data From 3 Tables...

Feb 12, 2006

Plugging away at my little message board that I am working on, I have hit another SQL snag. I am trying to select a list of all posts in a thread. I have to get each post, the name of the poster (which comes from a different table - referenced by userid), as well as some profil information, from a 3rd table (also referenced by the userid).

View 2 Replies View Related

Selecting And Inserting Data Into Another DB

Jan 28, 2004

Iam farely new to this so sorry for the newbie question.. but how do you select all data from one table and insert that data into the same table but in another sql database.

View 5 Replies View Related

Selecting Parts Of Data

Apr 20, 2008

Hey guys,

I was wondering if this is possible I have to be able to just select the number before the '-' in acolumn which is formatted like 123-456 so I just need the the 123 part.

Any ideas how this can be achieved?

Thanks.

View 8 Replies View Related

Selecting Data From Datalist

Jan 19, 2007



Hi all

I am having problem in selecting the data from my datalist. Here is teh sample code
<asp:datalist id="dlAttrName" runat="server" OnItemCommand="dlAttrName_SelectData" DataKeyField="attrID">
<ItemTemplate>
<asp:LinkButton ID="lbSelect" Runat="server" CommandName="Select" style="display:none">Select</asp:LinkButton>
<%# Container.DataItem("attrDef1")%>
</ItemTemplate>
</asp:DataList>
Private Sub dlAttrName_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlAttrName.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'Add eventhandlers for highlighting
'a DataListItem when the mouse hovers over it.
e.Item.Attributes.Add("onmouseover","????")
e.Item.Attributes.Add("onmouseout", "????")
'Add eventhandler for simulating
'a click on the 'SelectButton'
e.Item.Attributes.Add("onclick", ?????????????????????, String.Empty))
??????????????????? this should have something like this
Me.Page.ClientScript.GetPostBackEventReference(e.Item.Controls(1)
But I am not able to get the ClientScript option, I don't know which namespace should I import?

I don't know whether I am right or not.
Its urgent please reply back soon,any help will be useful.
Thanks!!!!!!!

View 1 Replies View Related

Selecting Data Wheere Values Contain Something

Nov 17, 2007

Hi,I have a message system, where people insert their message to the database, and others pick up their messages by selecting messages that have their username as the reciever ID.I have just intoduced bulk message sending - sending to multiple users. This requires many usernames being entered into the recievername column, seperated by a comma.Is there a way to select messages if the column name contains their username, rather than is their username? Because there may be more than one name, I would like everyone that has their name in the column to be able to retrieve the message, even if they arent the only reciever..Please ask if more explanation is needed!Thanks,Jon 

View 47 Replies View Related

Selecting Random Data From Sql Server

Jan 21, 2008

 I have three tables that are joined together to retrieve a piece of data.Table One has the columns pid1(PK), idTable Two has the columns pid1, qid1, idTable three has columns qid1, question, answerHere is my sql statement:SELECT  Table1.pid1, Table2.qid1, Table3.Question FROM Table1 JOIN Table2 ON Table1.pid1=Table2.pid1 JOIN Table3 ON Table2.qid1=Table3.qid1 WHERE Table1.pid=...(N)I put an elipsis because I'm stuck on how to proceed from here.  See I need to randomly select a value from column pid1 in table1 then use this value to replace N in the sql statement, then have the statement run and randomly return exactly one piece of data instead.Is this possible? How can you randomly get one piece of data from joining three table without a WHERE CLAUSE. 

View 1 Replies View Related

Selecting Data Using A Range Of Dates

Apr 30, 2006

For some reason this is just not "clicking" with me and the longer I stare at it the more I overcomplicate things and then I just confuse myself further...

Provided this relation showing where "pkey" and "skey" met on "ServiceDate":


Code:


skey pkey ServiceDate
--------------------------------------
123 1 11/12/2005
124 1 10/12/2005 *
123 2 10/02/2005
124 2 10/12/2005
124 2 11/12/2005
123 2 11/02/2005


I need to select out a list of distinct pkeys and skeys only when there was no meeting between the two in November 2005. In other words, this query would produce only one record - the starred record - when run against this sample table. This is because even though, for example, skey 124 / pkey 2 has an entry outside the desired range, it also has one inside the desired range. The same goes for the record outside our range for 123 and 2 - it also has a record inside our range.

At this point, I've come to the conclusion that I can first select all the distinct pkeys and skeys where the servicedate is not in 11/2005 then join it to a selection of distinct pkeys and skeys where the servicedate IS in the desired date range. Does that seem like the most straightforward way through this?

I don't get the impression that this is that complicated a problem, but it's one of those deals where I goofed up somewhere along the line, and now I think I'm really overthinking the problem, so I'd be much obliged if someone could give me a hearty slap to clear the ol' noggin.

View 1 Replies View Related

Access Violation When Selecting Data

Dec 6, 2005

Hi,

I have suddenly developed a problem when trying to select from a table. Even a standard select * from generates a SQL Dump exception handler. The table is below:

CREATE TABLE [Stagetb_GIDeptGroup] (
[f_GIImportID] [int] IDENTITY (1, 1) NOT NULL ,
[f_GIAction] [int] NOT NULL CONSTRAINT [DF_stagetb_GIDeptGroup_f_GIAction] DEFAULT (0),
[f_ImportBatchID] [int] NULL ,
[f_VisualDeptGroupID] [int] NULL ,
[f_DeptGroupName] [varchar] (40) COLLATE Latin1_General_CI_AS NULL ,
[f_DeptGroupTarget] [d_Percentage] NULL ,
[f_ExternalDeptGroupID] [int] NULL ,
[f_StatusID] [int] NOT NULL CONSTRAINT [DF_stagetb_GIDeptGroup_f_StatusID] DEFAULT (0),
[f_StatusDetailID] [int] NOT NULL CONSTRAINT [DF_stagetb_GIDeptGroup_f_StatusDetailID] DEFAULT (0),
CONSTRAINT [PK_stagetb_GIDeptGroup] PRIMARY KEY CLUSTERED
(
[f_GIImportID]
) ON [PRIMARY]
) ON [PRIMARY]
GO

When i run a dbcc checkdb it finds nothing, if i try and connect from a remote connection i get a general network error and when connecting from the local machine i get this Dump exception error:

2005-12-06 08:40:55.28 spid53 Error: 0, Severity: 19, State: 0
2005-12-06 08:40:55.28 spid53 language_exec: Process 53 generated an access violation. SQL Server is terminating this process..
2005-12-06 08:40:57.76 spid53 Using 'sqlimage.dll' version '4.0.5'
Stack Dump being sent to C:Program FilesMicrosoft SQL ServerMSSQLlogSQL00010.dmp
2005-12-06 08:40:57.76 spid53 Error: 0, Severity: 19, State: 0
2005-12-06 08:40:57.76 spid53 SqlDumpExceptionHandler: Process 53 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process..
************************************************** *****************************
*
* BEGIN STACK DUMP:
* 12/06/05 08:40:57 spid 53
*
* Exception Address = 00425E61
* Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
* Access Violation occurred reading address 00000000
* Input Buffer 70 bytes -
* select * from stagetb_GIDeptGroup
*
*
* MODULE BASE END SIZE
* sqlservr 00400000 00B19FFF 0071a000
* ntdll 77F50000 77FF6FFF 000a7000
* kernel32 77E60000 77F45FFF 000e6000
* ADVAPI32 77DD0000 77E5CFFF 0008d000
* RPCRT4 78000000 78085FFF 00086000
* USER32 77D40000 77DC5FFF 00086000
* GDI32 7E090000 7E0D0FFF 00041000
* OPENDS60 41060000 41065FFF 00006000
* MSVCRT 77C10000 77C62FFF 00053000
* UMS 41070000 4107CFFF 0000d000
* SQLSORT 42AE0000 42B6FFFF 00090000
* MSVCIRT 002A0000 002AFFFF 00010000
* sqlevn70 41080000 41086FFF 00007000
* NETAPI32 71C20000 71C6DFFF 0004e000
* wmi 76D30000 76D33FFF 00004000
* SSNETLIB 42CF0000 42D05FFF 00016000
* WSOCK32 71AD0000 71AD7FFF 00008000
* WS2_32 71AB0000 71AC4FFF 00015000
* WS2HELP 71AA0000 71AA7FFF 00008000
* SSNMPN70 410D0000 410D5FFF 00006000
* security 71F80000 71F83FFF 00004000
* SECUR32 76F90000 76F9FFFF 00010000
* crypt32 762C0000 76347FFF 00088000
* MSASN1 762A0000 762AFFFF 00010000
* VERSION 77C00000 77C06FFF 00007000
* userenv 75A70000 75B14FFF 000a5000
* mswsock 71A50000 71A8AFFF 0003b000
* DNSAPI 76F20000 76F44FFF 00025000
* winrnr 76FB0000 76FB6FFF 00007000
* WLDAP32 76F60000 76F8BFFF 0002c000
* rasadhlp 76FC0000 76FC4FFF 00005000
* wshtcpip 71A90000 71A97FFF 00008000
* SSmsLPCn 42CD0000 42CD6FFF 00007000
* ntdsapi 767A0000 767B2FFF 00013000
* msv1_0 76D10000 76D2CFFF 0001d000
* OLE32 771B0000 772D0FFF 00121000
* CLBCATQ 76FD0000 77047FFF 00078000
* OLEAUT32 77120000 771AAFFF 0008b000
* COMRes 77050000 77114FFF 000c5000
* sqloledb 01D80000 01DF2FFF 00073000
* MSDART 74C50000 74C6EFFF 0001f000
* COMCTL32 77340000 773CAFFF 0008b000
* comdlg32 763B0000 763F4FFF 00045000
* SHLWAPI 70A70000 70AD4FFF 00065000
* SHELL32 773D0000 77BC1FFF 007f2000
* MSDATL3 60E30000 60E44FFF 00015000
* comctl32 71950000 71A33FFF 000e4000
* oledb32 02020000 02084FFF 00065000
* OLEDB32R 01E00000 01E0FFFF 00010000
* xpsqlbot 42F00000 42F05FFF 00006000
* xpstar 410F0000 41133FFF 00044000
* SQLUNIRL 5C1B0000 5C1DCFFF 0002d000
* WINSPOOL 73000000 73022FFF 00023000
* SQLRESLD 42AC0000 42AC6FFF 00007000
* SQLSVC 42C40000 42C56FFF 00017000
* ODBC32 02150000 02181FFF 00032000
* odbcbcp 02190000 02195FFF 00006000
* W95SCM 41140000 4114BFFF 0000c000
* NDDEAPI 75940000 75946FFF 00007000
* odbcint 022B0000 022C5FFF 00016000
* clusapi 55560000 55570FFF 00011000
* resutils 750B0000 750C0FFF 00011000
* SQLSVC 43970000 43975FFF 00006000
* xpstar 439E0000 439EBFFF 0000c000
* DBGHELP 02420000 02432FFF 00013000
* msdbi 6BE90000 6BEABFFF 0001c000
* sqlimage 4A400000 4A40CFFF 0000d000
*
* Edi: 1ADA13F4: 00000000 1ADA1758 00000000 1ADA1400 00000001 00000000
* Esi: 00000000:
* Eax: 1ADA13E0: 009802E4 00000032 00000000 00000000 00000000 00000000
* Ebx: 1ADA13E0: 009802E4 00000032 00000000 00000000 00000000 00000000
* Ecx: 00000000:
* Edx: 1ADA1410: 00000000 6E006100 00000000 00000000 00000000 1ADA0030
* Eip: 00425E61: 7589018B 8B10FFFC F44D8BF0 A5A5A5A5 5EC38B5F 0D89645B
* Ebp: 0213DFE8: 0213E01C 004C4EB7 1ADA0020 00000000 1ADA1168 1ADC84D0
* SegCs: 0000001B:
* EFlags: 00010282: 0050004F 00300048 00300033 00560030 004F0042 004E0000
* Esp: 0213DFCC: 1ADA07F0 1ADA0020 00A0A4A0 1ADA13E0 0213E010 0092D7B0
* SegSs: 00000023:
************************************************** *****************************
-------------------------------------------------------------------------------
Short Stack Dump
00425E61 Module(sqlservr+00025E61)
004C4EB7 Module(sqlservr+000C4EB7)
0049DCD9 Module(sqlservr+0009DCD9)
0049DAF9 Module(sqlservr+0009DAF9)
00447078 Module(sqlservr+00047078)
004510FE Module(sqlservr+000510FE)
00415080 Module(sqlservr+00015080)
004592CE Module(sqlservr+000592CE)
005A7208 Module(sqlservr+001A7208) (SQLExit(unsigned long)+000523F6)
005A7099 Module(sqlservr+001A7099) (SQLExit(unsigned long)+00052287)
00446A83 Module(sqlservr+00046A83)
004510FE Module(sqlservr+000510FE)
00415080 Module(sqlservr+00015080)
004592CE Module(sqlservr+000592CE)
0041534F Module(sqlservr+0001534F)
00459A54 Module(sqlservr+00059A54)
004175D8 Module(sqlservr+000175D8)
410735D0 Module(UMS+000035D0) (UmsSystemUserContext::UmsSystemUserContext(class UmsScheduler *,struct UMS_SYSPARAMS *)+00000434)
4107382C Module(UMS+0000382C) (UmsScheduler::FiberEnabled(void)+000001D2)
77C37E53 Module(MSVCRT+00027E53) (_endthread+000000AA)
77E7D33B Module(kernel32+0001D33B) (RegisterWaitForInputIdle+00000043)

I am running Windows XP Professional & MSDE Service Pack 3. Any ideas anyone?

View 1 Replies View Related

SQL Server 2008 :: Selecting Data From XML?

May 24, 2015

preparation of a query to get the data from xml which has xmlns in first few lines.

Here I am attaching the xml file(not able to attach ".xml" file, so converted it to ".txt" ).

View 9 Replies View Related

Selecting Data Seperated By Commas

Jun 3, 2008

Have a column in my DB called _Venue, which has been populated with address information separated by commas, like this:

Address1,address2,address3,address4

The address has sometimes only a few lines, for example I may have just Address1 or just address1 and address2 filled etc.

I need to write a query that will individually select addressX, so I can pick and choose what part of the full address to use.

Can these be done?

Thanks in advance.

View 9 Replies View Related

Selecting Distinct Data Using Group By

Aug 4, 2013

I have an action log table which records when a registrant record was viewed by a compnay employee. I have an sql query like this:

SELECT [ID]
,[RegistrantID]
,[EmployeeID]
,[UserID]
,[CompanyID]

[Code] ....

and data is like this:

IDRegistrantID EmployeeIDUserID CompanyID VacancyID Action ActionDate
17931629515163213NULL 42013-08-04 16:45:40.457
17921629215163213NULL 42013-08-04 16:45:33.003
1791NULL15163213NULL 32013-08-04 16:45:23.660
1790162959162893NULL 42013-08-04 16:45:09.543

[Code] ....

I want to select distinct views to a registrantid record ( the first ones) in one year. if a registrant was viewed 10 tmes a year then it will show only first time it was viewed. If it was viewed 10 times by an employeed in 2 years then it will show first time it was viewed. if it was viewed by 2 employees of same company 10 times in one year then it first time viewed record will be shown. if it was seen 10 times by 2 employees of two different companies in one year then first record of two companies will be shown. do i need to use group by or what ?

View 1 Replies View Related

Data Not Selecting On Current Date

Oct 27, 2014

The following is the sql being executed in my Crystal report. There seems to be an issue with the same date request. Sometimes it shows data, other times not. We have data every day, we are a mass market company. Is there anything i can do for the sql to do select when from and to dates are the same?

SELECT "OEHIS1"."ODORD#", "OEHIS1"."ODORDT", "OEHIS1"."ODNTU$", "OEHIS1"."ODSHP#", "ICPRT1"."IARC11", "OEHIS1"."ODORDD", "ICPRT1"."IARCC4", "OEHIS1"."ODQTY#", "OEHIS1"."ODRQSD", "MFHHMH"."MHAWGT", "OEHIS1"."ODPRT#", "OEHIS1"."ODPRLC"
FROM ("S10M10"."ASTCCDTA"."EODDETAILS" "OEHIS1" INNER JOIN "S10M10"."ASTDTA"."ICPRT1" "ICPRT1" ON "OEHIS1"."ODPRT#"="ICPRT1"."IAPRT#") INNER JOIN "S10M10"."DLIB"."MFHHMH" "MFHHMH" ON "OEHIS1"."ODORD#"="MFHHMH"."MHORDP"

[Code] ....

View 4 Replies View Related

Selecting Data Based On A Variable

Jun 7, 2007

Hi All


I want to select a certainnumber of rows

select custno, amt, balance from customer where custno='customerno'
when showcust='r' then select rows where amt<balance
when showcust='c' then amt>balance etc
if showcust='' then show everything


Any insight will be greatly apprecaited.
Thanks

View 4 Replies View Related

Selecting Data From Multiple Rows

Jan 22, 2008

Here's my tables:

Students
-----------------------
StudentID | StudentName
-----------------------

StudentClasses
-----------------------
StudentID | ClassName
-----------------------

I'm trying to put data into a gridview in ASP.NET 2.0 like this:

Student | Classes
-----------------
Name1 | ClassName1 ClassName2 ClassName3
Name2 | ClassName1
Name3 | ClassName1 ClassName2

I just need to retrieve names of each class that a student is taking, then print them out one after another.

View 1 Replies View Related

Selecting Only Numeric Data From A String

Jan 12, 2006

Hello,I need to be able to select only the numeric data from a string that isin the form of iFuturePriceID=N'4194582'I have the following code working to remove all the non-numeric textfrom before the numbers, but it is still leaving the single quote afterthe numbers, i.e. 4194582'Any ideas or suggestions how to accomplish that? Thanks in advance.Declare @TestData varchar(29)Set @TestData = "iFuturePriceID=N'4194582'"Select Substring(@TestData, patindex('%[0-9]%', @TestData),Len(@TestData))TGru*** Sent via Developersdex http://www.developersdex.com ***

View 3 Replies View Related

Selecting From Two Tables With Different Data - Presenting In One Datalist

Oct 6, 2006

Hello!I have two tables:Pressreleases:| Pressrelease_ID | PressDate | FilePath | Title |PressLinks:| PressLink_ID | PressLinkDate | PressLinkUrl | PressText |I would like to select the the TOP 3 with the most recent dates from either Pressreleases or PressLinks, and present them in a DataList. How do I do that? Selecting from one table is no problem:SELECT TOP 3 Pressreleases.PressDate, Pressreleases.Filepath, PressReleases.Title FROM Pressreleases ORDER BY PressDate DESCHow do I select from both tables and rename the columns to Date, Path, Text so that I can use it in a Datalist?Thank you in advance!

View 4 Replies View Related

Selecting Data From A Temp Table In A SP -- Very Urgent

Sep 25, 2007

Hello. I have a SP. I am passing two variables to it that are comma seperated lists (ids) so that I can use an IN clause. But since I cannot use these CSV in an IN clause directly I wrote a temp table that first parses the CS list and creates a temp table with a single column of IDS.Then in a second temp table I am selecting the data using enrollment_id IN (Select enrollment_id From #temptable)Then the SP selects data from the second temp table.This works exactly the way it is supposed to work. But when I call the SP from ASP.NET it doesn't return any data. I just cant seem to return data by selecting from a temp table. And my ASP.NET code is correct because I commented out everything and just returned the parameters I was passing and that worked. So does anyone know how to select data from a temp table in a SP when executed from ASP.NET?I even tried Table Variables and same thing. It works great in SQL but when called from ASP.NET it doesnt return any data. I am guessing it's probably losing its scope. Any quick help would be appreciated. Thank you.Here is a snippet of the SP (even this fails):CREATE PROCEDURE [dbo].[returnEnrollments](@organization_id int, @test_item_list ntext, @enrollment_list ntext)As--select  @test_item_list as tilist, @enrollment_list as elistDeclare @report_start_date datetime;Declare @report_end_date datetime;Declare @test_item_id_list varchar(8000);Declare @enrollment_id_list varchar(8000);DECLARE @TestItemID varchar(10), @Pos intDECLARE @EnrollmentID varchar(10)--Set @IDList = @test_item_id_list;--Set @EnrollmentIDList = @enrollment_id_list;Set @test_item_id_list = Cast(@test_item_list As varchar(8000))Set @enrollment_id_list = Cast(@enrollment_list As varchar(8000))Select @report_start_date = report_start_date, @report_end_date = report_end_date From organization Where organization_id = @organization_id;-- Create a temp table to store all the enrollment idsIF OBJECT_ID('tempdb..#EnrollTemp') IS NOT NULLDROP TABLE #EnrollTempCREATE TABLE #EnrollTemp (enrollment_id int NOT NULL)SET @enrollment_id_list = LTRIM(RTRIM(@enrollment_id_list))+ ','SET @Pos = CHARINDEX(',', @enrollment_id_list, 1)IF REPLACE(@enrollment_id_list, ',', '') <> ''BEGIN    WHILE @Pos > 0    BEGIN        SET @EnrollmentID = LTRIM(RTRIM(LEFT(@enrollment_id_list, @Pos - 1)))        IF @EnrollmentID <> '' And @EnrollmentID > 0        BEGIN            INSERT INTO #EnrollTemp (enrollment_id) VALUES (CAST(@EnrollmentID AS int)) --Use Appropriate conversion        END        SET @enrollment_id_list = RIGHT(@enrollment_id_list, LEN(@enrollment_id_list) - @Pos)        SET @Pos = CHARINDEX(',', @enrollment_id_list, 1)    ENDENDSelect top 20 * From #EnrollTemp  Edit: Just used a DataReader instead of a datatable and it works. Dont know why it would fail with a datatable. 

View 4 Replies View Related

Need Help Selecting Data With Date -based Where Clause

Nov 18, 2003

OK. I have this query, works on another box fine.

SELECT *
FROM bookkeep RIGHT OUTER JOIN
acraccts ON LEFT(bookkeep.accnum, 9) = acraccts.p_accnum
WHERE (bookkeep.busdate = '03/09/10') AND (bookkeep.tradetype = 'S')

on my sql box, if i run it, i get no data.

i figured out that if i change the where clause to (bookkeep.busdate='2003/09/10') it works

OR

if i simply put SET DATEFORMAT YMD on the first line before the SELECT * that it also works.

my problem is the basic query is hard coded and i really can't change it.

is there a global sql server setting that will make my sql 2000 sp3 box recognize '30/09/10' as 2003/09/10?

View 1 Replies View Related

Inconsistant Row Counts When Selecting Data By Dates HELP!

Feb 28, 2000

Hi,

I currently think Im going mad!!

I have a large table (2+Million records, 2000+ new per day). If I want to count the records in one month, I could do :-

Select Count(*) from Table1 where Added_Date between '1999-12-01'
and '1999-12-31'

or

Select Count(*) from Table1 where Added_Date >= '1999-12-01' and
Added_Date <= '1999-12-31'

For these two above, I get the same result.

HOWEVER!!

If I then do:-

Select Count(*) from Table1 where Added_Date between '1999-12-01 00:00:00'
and '1999-12-31 23:59:59'
or use the >= and <= operators, the result is larger.

If I then do :-

Select Count(*) from Table1 where Added_Date between '1999-12-01 00:00:00.000' and '1999-12-31 23:59:59.999'
or use the >= and <= operators, the result is larger still but i believe this including more rows than there actually is?.

I can get over the problem programatically using Convert to truncate to a day, month or year however, I don't understand why the results are different.

Any Ideas as to why this is happening, A'm I being stupid!!!!!!!

(PS Added_Date has a non_clustered index which has been rebuilt twice and DBCC finds no errors)

Many thanks,


Peter Farley

View 1 Replies View Related

How To Escape Ampersand While Selecting Or Inserting Data?

Dec 10, 2003

How to escape ampersand while selecting or inserting data?
I know that for single quote we have to use two single quotes.
Thanks
m_nekkanti

View 2 Replies View Related

Indexes Being Improperly Used When Selecting Data Through A View

Nov 23, 2005

I am having a problem with indexes on specific tables. For some reasona query that runs against a view is not selecting the correct index ona table. I run the same query against the table directly and it looksfine. Can anyone give me some insight? Thanks.PRODUCTION1:CREATE TABLE MyTest1 (ID INT IDENTITY(1,1), COLUMN1 CHAR(10), COLUMN2CHAR(10))CREATE CLUSTERED INDEX IDX_MyTest1 ON MyTest1 ON (ID)CREATE NONCLUSTERED INDEX IDX_MyTest2 ON MyTest1 ON (COLUMN2, ID)ARCHIVE1:CREATE TABLE MyTest1 (ID INT IDENTITY(1,1), COLUMN1 CHAR(10), COLUMN2CHAR(10))CREATE CLUSTERED INDEX IDX_MyTest1 ON MyTest1 ON (ID)CREATE NONCLUSTERED INDEX IDX_MyTest2 ON MyTest1 ON (COLUMN2, ID)REPORTDB:CREATE VIEW MyTest1 ASSELECT ID, COLUMN1, COLUMN2 FROM PRODUCTION1..MyTest1UNION ALLSELECT ID, COLUMN1, COLUMN2 FROM ARCHIVE1..MyTest1While in PRODUCTION1:SELECT ID, COLUMN2 FROM MyTest1 WHERE COLUMN2 = 'Testing'--> Clustered index seek PRODUCTION1..IDX_MyTest2--> Results returnedWhile in ARCHIVE1:SELECT ID, COLUMN2 FROM MyTest1 WHERE COLUMN2 = 'Testing'--> Clustered index seek ARCHIVE1..IDX_MyTest2--> Results returnedWhile in REPORTDB:SELECT ID, COLUMN2 FROM MyTest1 WHERE COLUMN2 = 'Testing'--> Index seek PRODUCTION1..IDX_MyTest2--> Bookmark lookup PRODUCTION1..IDX_MyTest1--> Index seek ARCHIVE1..IDX_MyTest2--> Bookmark lookup ARCHIVE1..IDX_MyTest1--> Concatenate data and results returned

View 3 Replies View Related

Grouping Data And Selecting Highest Date

Aug 20, 2007

In SQL 2005 I have the following view:

SELECT TOP (100) PERCENT StockCode, Warehouse, QtyOnHand, QtyAllocated, QtyOnOrder, QtyOnBackOrder, DateLastSale, DateLastStockMove,
DateLastPurchase
FROM dbo.MBL_VW_AgedStock_Sales
ORDER BY StockCode

This basically shows a list of stock codes (there are multiple stock codes the same) and the last sold date. What i need to do is group the stock codes which are the same together, and show the latest date.

For example I could have the following:

STOCK CODE Last Date Sold

PC1113 11/01/2007
PC1104 15/03/2007
PC1113 15/02/2007

What I want to see is a list that shows PC1113 with its latest sold date, i.e.

STOCK CODE Last Date Sold
PC1113 15/02/2007
PC1104 15/03/2007

Any ideas?

Thanks
Kris

View 3 Replies View Related

Date Range Problem While Selecting Data

Feb 14, 2008

When im using the below query im getting the output, but when i change the starting date to 2006 I'm not getting the data for 2007 though it falls between the 2006 and 2008 range...



select * From dbname..tbl where date>= '03/jan/2007' and date <= '11/feb/2008' and Status= 'C' and ID is not null

AND (ACCOUNT = '25869' or ACCOUNT = '0' + '25869' )
Check and post your comments ASAP...

View 11 Replies View Related

Selecting Data Depending On Matrix Visibility

Feb 14, 2008

Hello,

I have a matrix report where I drill down from a business' divisional level to an office level. A subreport is generated by clicking on the relevant data field. However, when at divisional level, clicking on the data field simply generates the data from the first office row. I want it so that when the column is collapsed to divisional level, it shows the data for the entire division.

So... is there any way I can write an expression that creates different subreports based on whether a matrix column is expanded or collapsed?

Cheers,
Peter Marshall

View 4 Replies View Related

While Selecting Data From A Table, Disk Space Getting Abnormaly Low..

Feb 12, 2008

Hi All ..

I have 2 disk drive
C and D


The SQL Server data and log files are stored in D: drive

I have only 575 MB free spaces in C: drive

I have a Sql data base name StoresDB and there is a table name CustTBL

There are almost 6555500 rows in that table

My issues are whenever I am querying the CustTbl from Query Analyzer
(Select * from CustTbl)

The C: space decreased to 40 kb

And the same time,I am not getting all the rows in the query result
In Query analyzer Message Tab it is showing (6555151 row(s) affected)
But In the Grid Tab it is showing Grid#1 :6318847 rows or sometime less rows....

What is the reason to for these two issues?

I have updated the index and statistics for CustTbl TABLE but not got any changes
..
When I closed the query window the C: drive again showing 575 MB free space

View 8 Replies View Related

Selecting Data From SQL Table Based On A Time Period

Oct 11, 2007

I am trying to write a stored procedure that will select information from a SQL table based on a specific time.
For example I have a name field and a time field, I want to return just the names that were created between a specific time frame. ex between 3pm and 4pm.
Any thoughts?

View 21 Replies View Related

SQL Server 2005 Hanging - Selecting Uncommitted Data

Dec 5, 2006

We have found an issue with using MSS 2005 with odbc connections, some of
our code inserts data, then reselects the data back with a select using a
different handle. This hasn't caused any issues before but in one customer
this causes a lock up. The timeout error doesn't occur as you would expect
if trying to select data that is uncommitted by another user.

Although obviously we could re-code to avoid selecting uncommitted rows, can
anyone tell me why this works sometimes but not others. Some kind of
setting in MSS that we're unaware of maybe. The code works ok on other MSS
2005 & MSS 2000 servers and oracle & sqlbase.

View 1 Replies View Related

Selecting Maximum From A Varchar Field In A Data Flow

May 31, 2006

I have a problem selecting maximum values inside a data flow, when the field is varchar. For example, I could have an incoming text file with following rows (the real life problem is a bit more complicated, but the idea is the same)

ID Desc
1 Car
1 Truck
1 Bicycle
2 Horse
2 Cow

Now I would like to group by ID, and have the maximum value from the Desc field, resulting

ID Desc
1 Truck
2 Horse

I tried to sort the data flow first with ID ascending and Desc descending, followed by sort with ID ascending and "Remove duplicate sort values" turned on. However, the sort does not seem to select the first Desc value it gets, because the result is.

ID Desc
1 Bicycle
2 Horse

If you have any hints, how to tackle this problem, please help!

View 3 Replies View Related

What Is Wrong With This Code? Selecting Data With Stored Procedure With Multiple Parameters

Sep 22, 2005

oConn = New SqlClient.SqlConnection
oConn.ConnectionString = "user id=MyUserID;data source=MyDataSource;persist security info=False;initial catalog=DBname;password=password;"
oCmd = New SqlClient.SqlCommand
oCmd.Connection = oConn
oCmd.CommandType = CommandType.StoredProcedure
oCmd.CommandText = "TestStdInfo"
'parameters block
oParam1 = New SqlClient.SqlParameter("@intSchoolID", Me.ddlSchl.SelectedItem.ToString())
oParam1.Direction = ParameterDirection.Input
oParam1.SqlDbType = SqlDbType.Int
oCmd.Parameters.Add(oParam1)
oParam2 = New SqlClient.SqlParameter("@dob", Convert.ToDateTime(Me.txbBirth.Text))
oParam2.Direction = ParameterDirection.Input
oParam2.SqlDbType = SqlDbType.DateTime
oCmd.Parameters.Add(oParam2)
oParam3 = New SqlClient.SqlParameter("@id", Me.txbID.Text)
oParam3.Direction = ParameterDirection.Input
oParam3.SqlDbType = SqlDbType.VarChar
oCmd.Parameters.Add(oParam3)
oConn.Open()
daStudent = New SqlClient.SqlDataAdapter("TestStdInfo", oConn)
dsStudent = New DataSet
daStudent.Fill(dsStudent)  'This line is highlighted when error happens
oConn.Close()The error I am getting :Exception Details: System.Data.SqlClient.SqlException: Procedure 'TestStdInfo' expects parameter '@intSchoolID', which was not supplied.I am able to see the value during debugging in the autos or command window. Where does it dissapear when it comes to Fill?Could anybody help me with this, if possible fix my code or show the clean code where the procedure called with multiple parameters and dataset filled.Thank you so much for your help.

View 2 Replies View Related







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