Different Results With SET ANSI_NULLS

Nov 20, 2002

Could someone explain why these queries give two seemingly different
results?

set nocount on
set ansi_nulls off

create table #tmp1 ( col1 char(1) )
insert into #tmp1 values (null)
insert into #tmp1 values ('1')

select case when col1 <> '1' then 1 else 0 end from #tmp1




TIA...

View 5 Replies


ADVERTISEMENT

SET ANSI_NULLS ON

Sep 21, 2007

What does this mean and do?

SET ANSI_NULLS ON

View 2 Replies View Related

Question About Ansi_nulls

Nov 26, 1999

Hi,
I figure that my query below should return the records that I've inserted into test1 and test2 after I turn ansi_nulls off for my session. But the query does not return any records. Any ideas?

create table test1 (id int, create_date datetime null)
create table test2 (id int, create_date datetime null)

insert test1 values (1,null)
insert test2 values (1,null)

set ansi_nulls off

select *
from test1 t1 join test2 t2 on t1.id = t2.id
where t1.create_date = t2.create_date

View 2 Replies View Related

QUOTED_IDENTIFIER && ANSI_NULLS

Dec 2, 2007

does anyone know how to keep QA from adding the lines setting thesetwo options on and off along with blank lines at the beginning and endof every object you edit? i have searched quite a bit on this buthaven't been able to come up with anything.

View 1 Replies View Related

ANSI_NULLS And Null Comparison

Jul 20, 2005

Hi All,I'm converting some stored procs from Sybase to SQL Server, and I'mhaving serious problems with Null comparisons.When I run the code below on Sybase, it returns both rows. When I runit on MS SQL Server, it returns nothing. I have set ANSI_NULLS off inthe code (and on the session through Query Analyzer), but it doesn'tseem to make any difference. Am I missing something?---------------set ANSI_NULLS offdrop table #TestNullcreate table #TestNull (Field1 varchar(10), Field2 varchar(10))insert into #TestNull values (1, null)insert into #TestNull values (1,1)declare @TestVar varchar(10)select @TestVar = Nullselect * from #TestNull where Field1 = @TestVar---------------Thanks in advance,Saul

View 4 Replies View Related

Set QUOTED_IDENTIFIER And ANSI_NULLS On All Objects...

Sep 6, 2006

Is there any way via T-SQL to run through a database and ensure that QUOTED_IDENTIFIER and ANSI_NULLS is set for all stored procs and functions etc on a database without having to recreate every proc / fn ?

The reason this is an issue is I'm trying to take advantage of indexed views to get a performance increase in an application - but not all of the procs/fn's have historically been created with ANSI_NULLS and QUOTED_IDENTIFIER set - so any proc that's not set correctly will fail once the indexed view has been created.

I could I suppose, script out all the procs / functions and do a bit of search and replace to ensure that these are set correctly by recreating all procs and functions - but I'm trying to avoid doing that as I've over 500 databases to upgrade - a metadata hack may be preferable.


Thoughts or comments or possible alternative approaches are welcome...

View 3 Replies View Related

Linked Servers / Ansi_Nulls Option

Jul 10, 2001

Im having trouble accessing a linked/remote server from a powerbuilder app.

I can run the stored proc from QueryAnalyzer, but from the app I get the error message - 'heterogenous query must have ANSI_NULLS set option ON, set it and retry'.

Is the ANSI_NULLS option set for each db, or each server? And how can I check a DB or Server to see what the setting for ANSI_NULLS is? Does the local and remote/linked server/db need this option ON?

Any idea why this remote query works form QA but not from an application?

Thanks-
Scott

View 1 Replies View Related

Incorrect Settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

Jul 20, 2005

Getting an "incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."error after creating a view.We wanted a composite unique constraint that ignored nulls, so we setup a view using the following script:/* --- start --- */BEGIN TRANSACTIONSET QUOTED_IDENTIFIER ONSET ARITHABORT ONSET NUMERIC_ROUNDABORT OFFSET CONCAT_NULL_YIELDS_NULL ONSET ANSI_NULLS ONSET ANSI_PADDING ONSET ANSI_WARNINGS ONCOMMITGOCREATE VIEW vw_MyViewWITH SCHEMABINDINGASSELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULLGO/* --- end --- */and then added the constraint to the new view/* --- start --- */CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ONvw_MyView(Col1, Col2)GO/* --- end --- */I thought we were doing fine, 'til we started running some DELETEstored procedures and got the above error. The error also citedARITHABORT as an incorrect setting until we ran this script:/* --- start --- */USE masterDECLARE @value intSELECT @value = value FROM syscurconfigsWHERE config = 1534SET @value = @value | 64EXEC sp_configure 'user options', @valueRECONFIGURE/* --- end --- */TIA to anyone kind enough to shed some light on this for me. Is theresomething we should have done differently in creating the view andindex? If not, what's the procedure for working through thesesettings errors?I've read through some other threads on this subject, but didn'treally find what I was looking for. Thanks again for any help. Wouldbe appreciated.-matt

View 3 Replies View Related

Heterogeneous Queries, ANSI_NULLS, ANSI_WARNINGS

Oct 19, 2006

I have stored procedure:

EXEC sp_addlinkedsrvlogin @FailedRegionServerName, 'false', NULL, 'sa', 'pass'

DECLARE @a varchar(100)
SET @a = @FailedRegionServerName + '.Ithalat.dbo.Product'

DECLARE @s varchar(100)
SET @s = ' SELECT * FROM ' + @a
EXEC ( @s )

When I execute it I get the error:

Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.

Then I put
SET ANSI_WARNINGS ON
SET ANSI_NULLS ON lines into the procedure. Also checked "Ansi Nulls" and "Ansi Warnings" in the properties of SQL Server. It didn't work

Then I tried:

DECLARE @s varchar(300)
SET @s = 'SET ANSI_WARNINGS ON; SET ANSI_NULLS ON; SELECT * FROM ' + @a
EXEC ( @s )

I still got the error.

WHAT SHOULD I DO? HOW CAN I GET A TABLE CONTENT FROM A LINKED SERVER? Any will be appreciated, thanks a lot...

View 12 Replies View Related

ANSI_NULLs Settings For Existing Stored Procedures

May 8, 2008


As noted on the msdn the ANSI_NULLS for a stored procedure are set at time off creation (http://msdn.microsoft.com/en-us/library/aa259229(SQL.80).aspx).

Using:
- SQL server 2000

My question is; How do i get the details of a sp and display the ANSI_NULLS setting for it.
("select * from information_schema.routines" doesnt shows this information)

Is this possible in SQL 2000 (or 2005)?

View 3 Replies View Related

Error 7405: Heterogeneous Queries Require ANSI_NULLS...

May 8, 2001

I have a Stored Procedure I am trying to run that joins to a remote database. I am able to see everything in the QA just fine with this (courtesy of Anatha):

SELECT DISTINCT a.*
FROM LOCATION a,
LinkServer.MC_Card.webuser.LOCATION b
WHERE a.location_number = b.location_number

But I am trying to run this query in Stored Procedure(notice the 4-part name callout to the LinkedServer tables) which returns the error message:

Error 7405: Heterogeneous queries require ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.

Here is the Stored Procedure:
/****** Object: Stored Procedure dbo.spELRMCcardXtionByDate
Script Date: 4/24/2001 11:51:27 AM ******/

CREATE PROCEDURE dbo.spELRMCcardXtionByDate @dcid nvarchar(255), @startDate datetime, @endDate datetime
AS
-- declare @dcid nvarchar(255)
-- set @dcid = '1032'
SELECT STORE.[Str#], STORE.[Dcid#], E.card_number, E.program_number
, E.start_date, E.end_date, E.card_number, E.event_number
, E.status, E.budget, E.scheduled_date, P.tx_time, P.purchase_amount
, L.merchant_name
FROM (STORE INNER JOIN LinkServer.MC_Card.webuser.EVENT E ON STORE.[DemoID#] = E.event_number)
LEFT JOIN (LinkServer.MC_Card.webuser.LOCATION L RIGHT JOIN LinkServer.MC_Card.webuser.POS_TX P ON L.location_number = P.location_number)
ON E.event_number = P.event_number
WHERE (((STORE.[Dcid#])= @dcid)) AND E.scheduled_date BETWEEN @startDate AND @endDate
ORDER BY STORE.[Str#]
-- and E.card_number IS NOT NULL
GO

Any help greatly appreciated.

Thanks,
Bruce

View 2 Replies View Related

Error 7405: Heterogeneous Queries Require ANSI_NULLS

May 14, 2001

I am trying to create a stored procedure that updates a table on another server. It give the me the error about requiring ANSI_NULLS and WARNINGS being set. How can I set these if they are not already set? I tried setting them within the stored procedure, but does not appear to be working. Unless I am doing something wrong. I am trying to add SET ANSI_NULLS ON and doing the same thing for WARNINGS. Any thougts or suggestion on what to do? Thanks for the help

View 2 Replies View Related

Heterogeneous Queries Require The ANSI_NULLS And ANSI_WARNINGS Options To Be Set For

Sep 5, 2007

Hi,

I have a problem with linked servers.

I have an application running against a SQLServer 2005 Express. For some limitations, I had to access from the same application to another database, but I cannot change to another server.

So I have 2 created a second instances, where the first one refers the second one and I created synonyms in the first one to access to all the objects in the second one, to emulate a database in the first instances, but running on the second one. The final idea is to move to another server, but for the testing I use another instance.

But when I try to access to the aplication database, I hav the following error: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.

I searched solutions for this issue, but I only found to add SET ANSI_NULLS ON and SET ANSI_WARNINGS ON to my connection, before the queries, but I can't, because I cannot change the application.

If anyone can help me, I'd be veri greatfull

Best regards, Ariel

View 2 Replies View Related

Heterogeneous Queries Require The ANSI_NULLS And ANSI_WARNINGS Options To Be Set For

Nov 17, 2007

I have a SQL200 stored proc that gives me the error "Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query." when I try to execute it through the query analyzer.

I was able to create the stored proc fine but when I try to execute it through the query analyzer it gives me the above error. I do have Link Server select inside the stored proc. I have to turn of warnings inside the stored proc in order for it to not crash my vb6 recordset by putting in the SET ANSI_WARNINGS OFF
SET NOCOUNT OFF
SET ANSI_NULLS OFF
or else my vb6 recordset crashes.

When I created the sproc, I did what every one was telling me to do in the forums by putting in the

SET ANSI_WARNINGS ON
Go
SET NOCOUNT ON
GO
SET ANSI_NULLS ON
GO

CREATE Procedure usp_SprocName


AS
SET ANSI_WARNINGS OFF
SET NOCOUNT OFF
SET ANSI_NULLS OFF

Can someone help me?

View 4 Replies View Related

Native Client Ignores ANSI_NULLS Setting In Database

Oct 26, 2006

Hello,

I'm using the SQL Native Client to connect my VB6 application to my SQL Server 2005 database. My SQL Server 2005 database has ANSI_NULLS turned off. I have a query embedded in my VB6 application that uses the syntax "fieldName = NULL" in the WHERE clause. When I execute the query via the SQL Native Client, the query returns zero rows. When I execute the same query via the old OLEDB driver, the query returns many rows. If I change my query to "fieldName IS NULL" syntax, the problem goes away. However, I am more interested in figuring out why ANSI_NULLS are turned on when using the SQL Native Client even though my database has them turned off. Is there a connection string property that I can use with the SQL Native Client to ensure that the query is executed with ANSI_NULLS off?



Thanks

View 15 Replies View Related

UPDATE Failed Because The Following SET Options Have Incorrect Settings: 'ANSI_NULLS'

Oct 1, 2007


Hi, i have problem as subject says.
Db has table with 3 columns, ID, Key and Val. ID is primary key, Key has unique index and Val simple holds value in text format.
I have created DAL layer using .netTiers and CodeSmith. Generated procedures.sql has before every procedure set ANSI_NULLS to OFF.
When i read rows from table i print them on screen. When user changes value, that should also be updated in database.
When i select entity, its value is changed.
Here is code snipper.



Code Blockentity.Key = key;
entity.Value = value;
TransactionManager transactionManager = DataRepository.Provider.CreateTransaction();
try
{
transactionManager.BeginTransaction();
retVal = DataRepository.TestTableProvider.Update(entity);
transactionManager.Commit();
}
catch
{
transactionManager.Rollback();
throw;
}


I got an exception with message below:

UPDATE failed because the following SET options have incorrect settings: 'ANSI_NULLS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.

Also, class which hold previous code snipper supports caching, by using some kind of SqlCacheManager, which is above SqlCacheDependecy class. Database service broker is started by



Code Block
ALTER DATABASE <DB_NAME> SET ENABLE_BROKER


Server is SqlExpress 2005.
Application is in ASP.NET 2.0.




I also noticed next.
On first run, previous code passes without errors. On second run, update error appears.

This is log from sql server.



Code BlockQuery notification delivery could not send message on dialog '{822C7891-736E-DC11-836B-005056C00008}.'. Delivery failed for notification '<qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotificationhttp://schemas.microsoft.com/SQL/Notifications/QueryNotification">http://schemas.microsoft.com/SQL/Notifications/QueryNotification</A< A>>" id="1" type="change" source="database" info="restart" database_id="13" sid="0xE7C0751C9F7F6C4D9423096BBCC7FB69"><qn:Message>edd3e2dd-11ed-4d92-a0f4-5c674a90aecf;8b2095663cc6a9c297120e4c94d488555e97e54d</qn:Message></qn:QueryNotification>' because of the following error in service broker: 'The conversation handle "822C7891-736E-DC11-836B-005056C00008" is not found.'





Need fast answer.

Thanks in advance.

View 5 Replies View Related

Query To Linked Server:Oracle; Problems With ANSI_NULLS;ANSI_WARNINGS

Jul 20, 2005

When I perform a query on a linked Oracle server in the Query analyser Ihave noprboblem' to perform this query.However, when I create this query in a stored procedure I get a compilationerrorwhen saving this procedure. (Not when compiling; it has no errors)Server: Msg 7405, Level 16, State 1, Line 1Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS optionsto be set for the connection. This ensures consistent query semantics.Enable these options and then reissue your query.When I create a dynamic SQL statement then I can save this stored procedurewhen I run the stored procedure this same error happens.What do I have to do.Arno de Jong, The Netherlands

View 1 Replies View Related

Is There A Way To Hold The Results Of A Select Query Then Operate On The Results And Changes Will Be Reflected On The Actual Data?

Apr 1, 2007

hi,  like, if i need to do delete some items with the id = 10000 then also need to update on the remaining items on the with the same idthen i will need to go through all the records to fetch the items with the same id right?  so, is there something that i can use to hold those records so that i can do the delete and update just on those records  and don't need to query twice? or is there a way to do that in one go ?thanks in advance! 

View 1 Replies View Related

SQL Server 2008 :: Elegant Way For Returning All Results When Subquery Returns No Results?

Mar 25, 2015

I have four tables: Customer (CustomerId INT, CountyId INT), County (CountyId INT), Search(SearchId INT), and SearchCriteria (SearchCriteriaId INT, SearchId INT, CountyId INT, [others not related to this]).

I want to search Customer based off of the Search record, which could have multiple SearchCriteria records. However, if there aren't any SearchCriteria records with CountyId populated for a given Search, I want it to assume to get all Customer records, regardless of CountyId.

Right now, I'm doing it this way.

DECLARE @SearchId INT = 100
SELECT * FROM Customer WHERE
CountyId IN
(
SELECT CASE WHEN EXISTS(SELECT CountyId FROM SearchCriteria WHERE SearchId = @SearchId)
THEN SearchCriteria.CountyId

[Code] .....

This works; it just seems cludgy. Is there a more elegant way to do this?

View 4 Replies View Related

Need To Display Results Of A Query, Then Use A Drop Down List To Filter The Results.

Feb 12, 2008

Hello. I currently have a website that has a table on one webpage. When a record is clicked, the primary key of that record is transfered in the query string to another page and fed into an sql statement. In this case its selecting a project on the first page, and displaying all the scripts for that project on another page. I also have an additional dropdownlist on the second page that i use to filter the scripts by an attribute called 'testdomain'. At present this works to an extent. When i click a project, i am navigated to the scripts page which is empty except for the dropdownlist. i then select a 'testdomain' from the dropdownlist and the page populates with scripts (formview) for the particular test domain. what i would like is for all the scripts to be displayed using the formview in the first instance when the user arrives at the second page. from there, they can then filter the scripts using the dropdownlist.
My current SQL statement is as follows.
SelectCommand="SELECT * FROM [TestScript] WHERE (([ProjectID] = @ProjectID) AND ([TestDomain] = @TestDomain))"
So what is happening is when testdomain = a null value, it does not select any scripts. Is there a way i can achieve the behaivour of the page as i outlined above? Any help would be appreciated.
Thanks,
James.

View 1 Replies View Related

Stored Proc Results Are Displaying In The Messages Tab Instead Of Results Tab- URGENT

May 14, 2008




Hi All,
I have a stored proc which is executing successfully...but the results of that stored proc are displaying in the Messages Tab instaed of results Tab. And in the Results Tab the results shows as 0..So, Any clue friends..it is very urgent..I am trying to call this stored proc in my Report in SSRS as well but the stored proc is not displaying there also...Please help me ASAP..

Thanks
dotnetdev1

View 4 Replies View Related

Mind-boggling Gridview Results! Different Results For Different Teams..

Jun 18, 2008

Hi all, I have the following SQLDataSource statement which connects to my Gridview:<asp:SqlDataSource ID="SqlDataSourceStandings" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  SelectCommand="SELECT P.firstName, P.lastName, T.teamName, IsNull(P.gamesPlayed, 0) as gamesPlayed, IsNull(P.plateAppearances,0) as plateAppearances, IsNull( (P.plateAppearances - (P.sacrifices + P.walks)) ,0) as atbats, IsNull(P.hits,0) as hits, P.hits/(CONVERT(Decimal(5,2), IsNull(NullIF(P.atbats, 0), 1))) AS [average], (P.hits + P.walks)/(CONVERT(Decimal(5,2), IsNull(NullIF( (P.atbats + P.sacrifices + P.walks) , 0), 1)))  AS [OBP], (P.hits - (P.doubles + P.triples + P.homeRuns) + (2 * P.doubles) + (3 * P.triples) + (4 * P.homeRuns)) / (CONVERT(Decimal(5,2), IsNull(NullIF(P.atbats, 0), 1))) AS [SLG], P.singles, P.doubles, P.triples, P.homeRuns, P.walks, P.sacrifices, P.runs, P.rbis FROM Players P INNER JOIN Teams T ON P.team = T.teamID ORDER BY P.firstName, P.lastName"></asp:SqlDataSource>There are 8 teams in the database, and somehow the average and obp results are as expected for all teams except where T.teamID = 1.  This doesn't make sense to me at all!  For example, I get the following results with this same query: First NameLast NameTeamGPPAABHAVGOBPSLG1B2B3BHRBBSACRRBI

BrianAustinHope83432230.7187500.7352941.15625014612201221

GabrielHelbigSafe Haven62119141.0000000.9375002.1428576404111519

MarkusJavorSafe Haven82927200.8695650.8000001.21739114501021218

RobBennettMelville83029240.8275860.8333331.55172411904102117

AdamBiesenthalSafe Haven82929210.9130430.9130431.56521712631001015

ErikGalvezMelville82625180.7200000.7307691.24000011322101015 As you can see, all teams except for Safe Haven's have the correct AVG and OBP.  Since AVG is simply H/AB, it doesn't make sense for Gabriel Helbig's results to be 1.00000. Can anyone shed ANY light on this please?Thank you in advance,Markuu  ***As a side note, could anyone also let me know how I could format the output so that AVG and OBP are only 3 decimal places? (ex: 0.719 for the 1st result)*** 

View 2 Replies View Related

Removing Individual Results From A Paged Set Of Results.

Oct 19, 2007

Hi,
I have a web form that lets users search for people in my database they wish to contact. The database returns a paged set of results using a CTE, Top X, and Row_number().
I would like to give my users to option of removing individual people from this list but cannot find a way to do this.
I have tried creating a session variable with a comma delimited list of ID's that I pass to my sproc and use in a NOT IN() statement. But I keep getting a "Input string was not in a correct format." Error Message.
Is there any way to do this? I am still new to stored procedures so any advice would be helpful.
Thanks
 

View 3 Replies View Related

PASTE SQL RESULTS INTO EXCEL - Funny Results

Jan 30, 2008

Hi, when I copy and paste results from query analyzer into Excel it appears that values with zeroes at the end loose the zeroes. Example, if I copy and paste V128.0 into an Excel cell it comes out as V128 or if I copy 178.70 it displays as 178.7 - any ideas? I'm using SQL Enterprise Manager for 2000.

View 6 Replies View Related

Sql 0 Results

Aug 9, 2006

Hi, i wanted to know if there is a way that we can know if Sqldatasource retrieved 0 results, i wanted that cause i want to make a condition that if 0 results retrieves a page with the text "No news"...Thanks in advance.

View 2 Replies View Related

SQL Qry To Get The Following Results.....

Jan 12, 2006

SQL Server 2000
i have made a table(EmployeeRole) consists of the following fields :



Appname
EmployeeID
RoleID
ProjectID

QMS
1353
1
BI0362

QMS
1353
3
BI0362

QMS
1379
1
BI0362

QMS
1379
13
BI0362and another table called employee



EmployeeID
FirstName
LastName

1353
Wissam
Zein

1379
Wassim
Zeinand another table called Role:



RoleID
RoleName

1
User

3
PD

13
TeamLeaderi need to make a query that gives the following results:



EmployeeID
EmpName
RoleID
RoleName

1353
Wissam Zein
3
PD

1379
Wassin Zein
13
TeamLeader
thank you for the help and for the time

View 5 Replies View Related

Results From SP

Jan 16, 2001

Can someone give an example on how to insert data into a table that I get from running a any System Stored Procedure.

Thank You,
John

View 2 Replies View Related

Results

May 25, 2006

I have some SP's I run once a month and each SP takes a few mins to run and when I batch em together in one shot, I hate sitting there waiting for them to finish
whats the easiest way to report back the status of the exec?

Ex:
Set NoCount ON
EXEC StatesUpdateZipTableUpdate 'AE'
EXEC StatesUpdateZipTableUpdate 'AK'
EXEC StatesUpdateZipTableUpdate 'AL'
EXEC StatesUpdateZipTableUpdate 'AP'
EXEC StatesUpdateZipTableUpdate 'AR'
EXEC StatesUpdateZipTableUpdate 'AZ'

How would I get it to report the results after each Exec?
In otherwords Id like to create a progress bar......

View 3 Replies View Related

Getting Results Between 10 And 20

Nov 10, 2006

Here is my query

SELECT ItemName,ItemDesc FROM CATAGORY

This query returns over 80 results but I only need the results between 10 and 20 how can I modify the query to do that?

View 7 Replies View Related

Help With Results

May 16, 2008

Hi everybody

I have two tables which are info and pubssubcribe. each record on the info table has a corresponding subscription on the pubssubscribe table. I need to extract those records on the pubssubscribe with the infid appearing more than once and having the pubid BETWEEN 19 AND 22 and count the records grouped on infid
couldn't get thru with the code below

Here's my sql code
SELECT info.infid, info.infname
FROM info INNER JOIN
pubssubscribe ON info.infid = pubssubscribe.pubinfid
WHERE (info.infcond IS NULL) AND (pubssubscribe.pubid BETWEEN 19 AND 22 AND pubssubscribe.pubid > 1) AND (info.infid > 1)
ORDER BY info.infid

thanks

View 2 Replies View Related

Results To .txt

Jun 16, 2008

Hi,

How could I export results into a text file? Have been copying and pasting results into excel, but have been getting memory errors, whcihw e are working on fixing. In the meanwhile, I'd like to send these results (about 200,000 rows)into a .txt file as I execute teh query.

I use ms sql 2005

Thanks.

View 1 Replies View Related

Top Ten Results

Feb 23, 2006

Hi can anyone help me maybe im just being thick but i cant for the life of me work out how to get the top ten results based on the highest number within a column

ie.

top2 would be

name1 4
name2 8
name3 102
name4 113


i want name3 and name4 to be returned

SIMPLE well it should be aRRRRGGG HELP!!!

i have tried using max but that only returns the highest
how i get the next highest etc i dont know

View 1 Replies View Related

1 Row Results Per ID

Aug 23, 2007

Hey guys, I have a small issue that I'm not sure how to solve. I have 2 tables that I'm working on, that has the UserID, LastName, FirstName, DocumentDesc. Each DocumentDesc has its own DocumentTypeID

1st table is called Person
Fields(UserID, LastName, FirstName)

2nd table is called Documents
Fields(UserID, DocumentTypeID, DocumentDesc)

The query that I have for this is the following:




Code Snippet
Select a.UserID, a.LastName, a.FirstName, b.DocumentDesc
From person a
Join documents b on
a.UserID = b.UserID
Where b.documenttypeid = '126d2beb-f7a1-4bf1-b9c0-dded37d3a6bc' OR
b.documenttypeid = '9087956e-1fb0-4f3d-ba33-ef31d79141af'
Order by LastName





The first DocumentTypeID is for RESUME and the Second one is for TRANSCRIPT




This is a sample from the query above


UserID LastName FirstName DocumentDesc
1 Smith Paul Resume
1 Smith Paul PhdStatistics
1 Smith Paul MS Applied Statistics
1 Smith Paul MS Operation Research
2 Jackson Jane Resume
2 Jackson Jane MS Information Systems

What I'm trying to do is get this in on one line like so:

UserID LastName FirstName DocumentDesc DocumentDesc DocumentDesc DocumentDesc
1 Smith Paul Resume PhD Statistics MS Applied Statistics MS OperResearch
2 Jackson Jane Resume MS InforSystems

Note: Not all names have the same amount of documents.

View 5 Replies View Related







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