SQL 2012 :: View Giving Different Results?

Nov 4, 2014

I have a view over 5 tables that has started giving unreliable results. There are three records that should be different, but in a production Access database, the view is giving three identical records where there should be three unique records. I have tested the view within SQL Server Management Studio and it gives the correct records there. But, I have attached this same view into the same Access database with two separate names. One instance of the view within Access database gives the correct records, and the other gives the incorrect (duplicated) records. I have attached screen shots that show these two separately named incarnations of the same SQL View, with the duplicated data, or the unique data highlighted.

I have also included the SQL query specs for this view.

what I can do to this view in order for it to always give us the unique records that we need, rather than sometimes the correct records, and sometimes the incorrect records.

Correct 3 records:

Incorrect 3 records:

[URL]

View 4 Replies


ADVERTISEMENT

SQL Server 2012 :: View Not Displaying All Results

Aug 7, 2014

I have created a view thats pulling data from two different tables to combine them into one report.

table 1 lists the client code and table 2 lists the client partner and they're linked by a variable.

When running the report the result shows the client codes with their respective partner however any client codes that didn't have a partner are not displaying in the report and I need all client codes to be displayed even if there's no partner.

Is there a way I can make this display all results and if the client partner doesn't exist for it to still display as 'Null' for the partner but still display the client code?

Script:

SELECT TOP (100) PERCENT C.cltCode AS ClientCode, C.cltSortName AS SortName, C.cltTerminationDate AS [Term date], dbo.vcltAttrib6.ainTVal AS Department,
C.objInstID AS ClientID
FROM dbo.cdbClient AS C INNER JOIN
dbo.vcltAttrib6 ON C.objInstID = dbo.vcltAttrib6.ainObjectInstID
GROUP BY C.cltSortName, C.cltTerminationDate, dbo.vcltAttrib6.ainTVal, C.objInstID, C.cltCode
ORDER BY ClientID

View 2 Replies View Related

SQL Server 2012 :: View Results Not Displaying Nil Columns

Sep 5, 2014

I have a view I've created which displays client sortname, partner and date added which displays 7 results.

When I add another table to this view to display the Industry it then only gives me 4 results as the other 3 results have no Industry instead of giving me the 7 results and showing the Industry column as empty for the other 3.

Is there a way I can make it show all 7 results and havethe column where the industry is empty display the other results instead of not displaying any results at all for them?

Script:
SELECT dbo.cdbClient.cltSortName AS ClientName, dbo.vcltAttrib4.ainTVal AS ClientPartner, dbo.vcltAttrib422.ainDVal AS [Date Added],
dbo.cdbAttribInst.ainTVal AS Inudstry
FROM dbo.cdbClient LEFT OUTER JOIN
dbo.cdbObject ON dbo.cdbClient.cltCategoryID = dbo.cdbObject.objID LEFT OUTER JOIN

[Code] ....

In the above script the cbdAttribInst table has the Industry column I need which is 'ainTVal'...

View 8 Replies View Related

SQL Server 2012 :: How To Write Text Out To Grid View In Results Tab

Dec 1, 2014

I can create a string into a local "@" variable. It can include a date/time, and text for my timing testing.

I need to be able to send that string to the results window where table output goes, rather than to the message window where a PRINT statement goes.

How do I do that?

View 2 Replies View Related

SELECT Statement Not Giving Me Desired Results

Jun 27, 2006

I have the following SELECT statement attached to a dropdown box:
SELECT [Workshop] FROM [Workshops] WHERE Workshop <> (SELECT Workshop FROM Workshop_Registration WHERE FullName = @FullName AND Completed = @Completed) ORDER BY [Workshop]
I am trying to get all workshops (50 or more) from the WORKSHOPS table that the logged in user is not already registered for.  This works perfectly as long as the student is registered for at least 1 class.  It populates the dropdown with all of the other classes.  If they aren't registered for a class then it doesn't list any classes.  The problem is definitely the subquery, but how do I make it to where if the subquery doesn't return any results (student not registered for anything), I get all of the workshops in the dropdown?  Any help is appreciated!
MikeD

View 2 Replies View Related

Using Distinct And Count (*) Is Not Giving The Results Expected

Feb 12, 2008

I have 2 tables.  Product, ProductCategory.
Product table consists of (productid, productname, producttypeid, createdate, portid)
productcategory consists of (productid, categoryid, productcategoryid, categoryid, prodroletypeid, createdate)
I want to write sql query to get the unique products.  So the count should only give one value/resuls.  But when I run the following query, I am getting more than one rows
select count(distinct categoryid) as uniquecat
from productcategory as pc, product as p
where pc.prodroletypeid in ('P', 'F')
and pc.createdate <= dateadd(d, 30, getdate())
and p.portid = 100
group by pc.productid
 
 

View 3 Replies View Related

JOINs And SUMs Not Giving Expected Results

Jul 20, 2005

I have just added a third table to a query and I am no longer gettingthe results I am expecting.Three Tables:CUSTINVOICEJOUR (Header Table)CUSTINVOICETRANS (Line Item Table)MARKUPTRANS (Additional Header Info)CUSTINVOICEJOUR has a one to many relationship to CUSTINVOICETRANS.CUSTINVOICEJOUR has a one to many relationship to MARKUPTRANS.I need to sum an integer column from MARKUPTRANS, in rows that arerelated to CUSTINVOICEJOUR, and include that output with my querybelow, which right now has a row for each CUSTINVOICETRANS record:SELECT CUSTINVOICEJOUR.INVOICEAMOUNT, CUSTINVOICETRANS.QTYFROM CUSTINVOICEJOUR INNER JOINCUSTINVOICETRANS ON CUSTINVOICEJOUR.INVOICEID =CUSTINVOICETRANS.INVOICEIDWHERE (CUSTINVOICEJOUR.DATAAREAID = 'acm') AND(CUSTINVOICETRANS.DATAAREAID = 'acm')The above works fine - a row for each record in CUSTINVOICETRANS withthe header info in there as well.I tried the query below to add a SUM() from MARKUPTRANS, but when I runit, I get one row with strange results in it - not what I expected.What am I doing wrong?SELECT CUSTINVOICEJOUR.INVOICEAMOUNT, CUSTINVOICETRANS.QTY,SUM(MARKUPTRANS.VALUE) AS FreightValueFROM CUSTINVOICEJOUR INNER JOINCUSTINVOICETRANS ON CUSTINVOICEJOUR.INVOICEID =CUSTINVOICETRANS.INVOICEID INNER JOINMARKUPTRANS ON CUSTINVOICEJOUR.RECID =MARKUPTRANS.TRANSRECIDWHERE (CUSTINVOICEJOUR.DATAAREAID = 'acm') AND(CUSTINVOICETRANS.DATAAREAID = 'acm') AND (MARKUPTRANS.DATAAREAID ='acm')GROUP BY CUSTINVOICEJOUR.INVOICEAMOUNT, CUSTINVOICETRANS.QTY,MARKUPTRANS.MARKUPCODEHAVING (MARKUPTRANS.MARKUPCODE = 'Freight')

View 1 Replies View Related

Reporting Services :: Results Are Giving 5 Rows Instead Of 1 Row?

Jul 30, 2015

I have created a query that is suppose to display the results of opportunities won during a time period the user selects.

When I run the report, I get 5 rows of the exact same result.

How come I am getting this?

DECLARE @DateStartDATE = '2011/02/25';
DECLARE @DateEndDATE = '2015/12/27';
DECLARE @UserVARCHAR(100) = 'Linda Smith';
SELECT
OPP.customeridnameAS 'Customer Name',

[Code] ....

View 4 Replies View Related

Giving Permission To View CERTAIN Records

Dec 4, 2006

I've been looking through permissions to see if it's possible to grant a user permission to see only certain records from a table.

For example:

I'm granting users to view records in the table 'Sales', but I only want the users to see their respective data.

User A should only be able to see Sales where Sales.Location = 1

User B should only be able to see Sales where Sales.Location = 2

... and so on.

I believe I've read this is possible, but in looking through the permissions you can define, I've only found where you can limit the columns a user sees, not records.

Anyone have any ideas or did I just remember something wrong?

View 6 Replies View Related

VIEW On MS SQL Giving Different Result That Query On ACCESS

Mar 13, 2008

Good morning,
I'm trying to create a view on SQL Server based on a query that i use on Access. The query returns detailed data from a table based on ID's selected and saved into another table.

the thing is, on access it returns back 5 records<which is a correct output> , while on SQL. its returning only one record. what could be the issue here ?

thank you,

View 3 Replies View Related

SQL 2012 :: DTSX Giving Errors - Object Reference Not Set To Instance Reference

Sep 10, 2014

I am using vs 2010 to write my dtsx import scripts.I use a script component as a source to create a flat file destination file.Everything have been working fine,but then my development machine crashed and we have to install everything again.Now when i use the execute package utility to test my scripts i get the following error:

Error system.NullReferenceException: Object refrence not set to an instance reference.

In PreExecute section
TextReader = new system.io.streamreader(" file name")
In the CreateNewOutputRows:
dim nextLine as string
nextLine = textReader.ReadLine

[code]...

is there something which i did not install or what can be the error?

View 0 Replies View Related

Query Results To A View

Nov 15, 2004

I have a table in a database that has very old and not very relational and I want to create a quick view to show the information in a better way. Let's say that the table has 4 fields : id , child1, child2, child3. I want to create a view from this table that will show two fields : id and child. So, my table currently looks like this:

id child1 child2 child3

1 sam bob chris

and i would like it like this......

id child

1 sam

1 bob

1 chris

Can anybody help me? Thanks in advance,

Bob

View 3 Replies View Related

Modify Results Of A View

Mar 10, 2006

Sigh, probably simple, but somehow I just can't get it to work..

I have a complex view which generated about 9000 results, and I use
a SP to select certain results from that view. How can I modify the
results of the SP? for example I want to add a zero to every single
companynumber the SP gives me...

*it's friday, i know*
Any help would be appreciated!

/Erwin

View 1 Replies View Related

Strange View Results

Jul 20, 2005

Bit of an obscure one here, so please bear with me. I have two copiesof a database which should be identical. Both have a complex viewwhich is identical. I can open the views and the data is as expectedand match. I can query it in several ways as detailed below. The 5thversion of the simple query below based on the second copy of the viewfails, but works under the first copy./*1 Statement below works*/SELECT *FROM AgentHierarchyWHERE AdviserId = 6069819/*2 Statement below works*/SELECT *, AH.AdviserLastName, AH.AdviserFirstNameFROM AgentHierarchy AHWHERE AdviserId = 6069819/*3 Statement below works*/SELECT *, AH.AdviserLastName + ', '+ AH.AdviserFirstNameFROM AgentHierarchy AHWHERE AdviserId = 6069819/*4 Statement below works*/SELECT AH.AdviserLastName + ', '+ AH.AdviserFirstNameFROM AgentHierarchy AH/*5 Statement below fails*/SELECT AH.AdviserLastName + ', '+ AH.AdviserFirstNameFROM AgentHierarchy AHWHERE AdviserId = 6069819The error I get is to do with conversion of data within the view. It'sa little complex, but the view works fine. It looks to me like when Irun the 5th statement above, it re-runs the view and then finds anerror.So, I took the complex view and ran that with the data output into atemporary table with the queries above run against that, and it worksfine. The problem is that the statement I need is based around the 5thone above (part of an update statement).I'm struggling to understand why some of the queries above work andone doesn't. If you look at 3 and 5 I'd expect them both to fail. Ifit failed consistently I could get further into it.The problem is that it's a little difficult to get the view itselfchanged as it was supplied by a third party, but if it hasn't changedand the data hasn't changed then it's got to be something else causingthe problem.Anyway, as I said, it's a bit obscure, but if this sounds familiar I'dbe interested in your opinion.Thanks in advance.

View 4 Replies View Related

Getting Webservice Results Into A View

Mar 25, 2008

We have a large number of applications that use various sql databases. They need to validate and do lookups of information such as employees and addresses. Currently, we load data from oracle into our main sql server and push the data out to various servers. This could perhaps be simplified with replication, but is now done with some dts packages.

We are wondering if there could be a better way to do this. We would like to go directly against oracle for the address data and to sql for the employee info.

An idea I had was to have our programmers create a web service that could be called from our .net applications. That works fine for in house applications, but some vendor applications need to see a table or view. We can write a CLR proc that can connect to the web service and provide data in table format I believe.

How could we get this into a view? I've tried creating a function that calls the proc and returns the table-valued variable to the view, but it seems the functions doesn't like using 'exec myProc' in the select_statement parameter.

I suppose we could have them make an additional connection to the lookup information, stored on a central database...they are probably doing this anyway to get to the validation db on the same server.

View 5 Replies View Related

Create DB View To Show Results

Sep 10, 2007

I have 2 Table
Authors
ID Name
1 Clint
2 Voke

Books
BookID ID BookName Price
1 1 Book1 10
2 1 Boo21 12
3 2 Book3 6
4 1 Book4 13
5 1 Book5 2

Now I want to List All Authors and only show Most Expensive book Name of each Author.
So I need this Fields :ID,Name,BookName,BookID,Price.

How could I Write SQL query For It (I want to show results in DB Without Using SP).
I want to Create NEw Views Which Shows my required Results.

thanks,

View 15 Replies View Related

SQL 2000 View VS. Sproc Show Different Results

May 9, 2005

I have a sproc in my database that when editing in VS 2003 shows different results.
The sproc code is:
ALTER PROCEDURE dbo.VMUsage_GetRaw
@VMBox nvarchar,@StartDate datetime,@EndDate datetime
AS
SET NOCOUNT ON
SELECT      *FROM          VMRawUsageWHERE      (ACCOUNT = @VMBox) AND  (CONVERT(datetime, DATE + ' ' + TIME) > @StartDate) AND  (CONVERT(datetime, DATE + ' ' + TIME) < @EndDate)
When I open the SQL statement in the designer and run (and enter my parameters) I get a recordset returned, but when I just "Run Stored Procedure" and enter the same parameters I get no results.  The same occurs when I run the sproc from my website (no results).
Any ideas what is happening between the two?

View 1 Replies View Related

Transfer View Results From SQL 7 To Excel/Access

Apr 29, 1999

Wendy,

I do not know if you can see my reply after yours. Any way I try it here again.

In the DTS Export Wizard, after select the source (SQL Server)and destination (Excel),
I have 2 choices:Table copy or query.

When I use query, I can place my sp there, and the export works fine exactly as you recommended.
Thanks a lot.

But when I selected a table copy, I was given a "Select Source Tables" popup form, I can
see all the table names there, but can not find any views in the database. I do not know why.
Am I in the right place this time?

Thank you very much for your quick help.

Charlie

View 1 Replies View Related

Making A View That Shows The Results Of Several Different Queries.

Dec 21, 2005

Hello,I am trying to create a view that shows the followingField1: Sum of Amounts from Table AField2: Count of Amounts from Table AField3: Sum of of Amounts from Table BField4: Count of Amounts from Table B......Field3: Sum of of Amounts from Table HField4: Count of Amounts from Table H......Things are a bit more complex but this is the gist.I am using SQL 2000.I know how to do this pretty easily using a stored procedure. But howcan I do it in a view? A SQL server won't meet my needs in thissituation.I tried OpenQuery ('myserver', 'exec myprocedure') but get the messagethat my server is not configured for data access. I tried the systemstored procedure to set data access to true but nothing seemed tohappen.I also tried Select * from (Select Statement1, select statement2)but got syntax error at the comma between statement1 and statement2.Trying to use select Statement1 as ABC to does not seem to work either.Is there a way to do what I want without making 15 views and then afinal view that shows them all together? I know I could probably dosomething by creating a ton of functions, but it really seems thisshould not be that hard...I am definitely open to any easy suggestions!Thanks,Ryan

View 3 Replies View Related

Howto Use The Query Results As View Column?

Sep 17, 2006

Hi All,I have two tables, one is about member infomations, the other is thecatergoriesmember_info(id,name,email,phone)member_categories(id,category)how can create a view like this (id, name, category1, category2,category3) with high performance?Thanks in advance.Joshua

View 2 Replies View Related

How To View Results From Sequence Clustering Using DMX Query

Mar 4, 2007

somebody help me??

View 4 Replies View Related

Write Query To Show Results In DB View -Advanced-

Sep 10, 2007

I have 2 TableAuthorsID Name1 Clint2 Voke
BooksBookID ID BookName Price1           1        Book1  10 2           1        Boo21  12 3           2        Book3  6 4           1        Book4  13 5           1        Book5  2
Now I want to List All Authors and only show Most Expensive book Name of each Author.So I need this Fields :ID,Name,BookName,BookID,Price.
How could I Write SQL query For It (I want to show results in DB Without Using SP).I want to Create NEw Views Which Shows my required Results.
thanks,
 
 

View 2 Replies View Related

Transfer View Results In SQL7 To Access/Excel

Apr 29, 1999

Hi,

Does anyone know the method to transfer result data of a view or stored procedure
in MS SQL 7.0 to MS Access or Excel , Manually or automatically? I did not find the
right tool in SQL 7 to do so.

I notice we can transfer table from SQL 7 to MS Access / Excel through DTS. But did not
find any tool/menu to transfer result of view / stored procedure.

I am new to SQL 7. Maybe this is a silly ?. Any help will be appreciated.

Charlie

View 2 Replies View Related

Create View, Varied Results Depending On Row Size

Mar 11, 2004

This is the same issue as deinfed in http://www.dbforums.com/t987543.html

I've done some additional testing and got it down to the below

SQL2000 DB
Linked Server to DB2 using client access odbc, and MS OLE DB for ODBC

Varied results depending on the row size of the views.

See the below examples.

CREATE VIEW BLHDR_TEST
AS
SELECT STNST
FROM LURCH_PARADB.S102D4LM.PARADB.BLHDR

STNST CHAR(25)

TOTAL ROW WIDTH (25)

SELECT * FROM BLHDR_TEST

Returns 20971 rows * 25 = 524,725


CREATE VIEW BLHDR_TEST
AS
SELECT STNSHTNAM, STNST
FROM LURCH_PARADB.S102D4LM.PARADB.BLHDR

STNSHTNAM CHAR(12)
STNST CHAR(25)

TOTAL ROW WIDTH (37)


SELECT * FROM BLHDR_TEST

Returns 14169 rows * 37 = 524,253


CREATE VIEW BLHDR_TEST
AS
SELECT STNADD1, STNSHTNAM, STNST
FROM LURCH_PARADB.S102D4LM.PARADB.BLHDR

STNADD1 CHAR(40)
STNSHTNAM CHAR(12)
STNST CHAR(25)

TOTAL ROW WIDTH (77)

SELECT * FROM BLHDR_TEST

Returns 6808 rows * 77 = 524,216


CREATE VIEW BLHDR_TEST
AS
SELECT STNCTY,STNADD1, STNSHTNAM, STNST
FROM LURCH_PARADB.S102D4LM.PARADB.BLHDR

STNCTY CHAR(25)
STNADD1 CHAR(40)
STNSHTNAM CHAR(12)
STNST CHAR(25)

TOTAL ROW WIDTH (102)

SELECT * FROM BLHDR_TEST

Returns 5140 rows * 102 = 524,280



Test #1 Returns 20971 rows * 25 = 524,725
Test #2 Returns 14169 rows * 37 = 524,253
Test #3 Returns 6808 rows * 77 = 524,216
Test #4 Returns 5140 rows * 102 = 524,280

With the similarity of the total byte count returned, I would assume that a buffer or something is being overrun, is this a configuration parameter possibly.


If I perform the select against the linked table as such

Select * (for fields list)
From LURCH_PARADB.S102D4LM.PARADB.BLHDR

I get all rows returned. The issue only exist when accessing the views that are created against the linked server.


Any thoughts or ideas are appreciated.

View 1 Replies View Related

Store Procedure To Copy View Results To A Table

Feb 17, 2014

I am looking for an example of a store procedure that will run a existing view and copy the results to a table. Every time it runs the table needs to be truncated. Will run once a day.

My view is a follows

SELECT PClass
FROM mydatabase.dbo.ProductClassDes
WHERE (ProductClass <> '_RBS') AND (ProductClass <> '_EDT') AND (ProductClass <> '_BMS') AND (ProductClass <> '_PAZ') AND (ProductClass <> '_PBC')

View results need to be copied to a table tblCurrentProductClasses that will only contain one field PClass.

View 2 Replies View Related

(SQL 2000) Incorrect Results When Using An Outer Join And A View!

Mar 29, 2008

Hi,
I have a query written in SQL 2000 which returns incorrect result. The query uses left outer join and a view. I read an issue related to this in one of microsoft bug report in this article http://support.microsoft.com/kb/321541.

However, there's a slight difference in the sympton second bullet wherein instead of a expression the query returns a fixed string for one of the column value.

Although the issue mentioned in article seems to be fixed. The later one still seems to be reproducible even with Service Pack 4. However, this issue doesn't appear in SQL Server 2005.

Here's the query to reproduce this error.



Code Snippetcreate table t1 (pk1 int not null,primary key (pk1))
create table t2 (pk1 int not null,label1 varchar(10) not null,primary key (pk1))
go
insert into t1 values (1)
insert into t2 values (2, 'XXXXX')
go
create view V as
select pk1, 'ZZZZ' as label1 from t2
go
select A.pk1 as A_pk1, B.pk1 as B_pk1, B.label1 as B_label1
from t1 as A left outer join V as B on A.pk1 = B.pk1
go

This query is similar to the one mentioned in the article except that in the SELECT clause of CREATE VIEW statement I am passing a fixed value for column "label1".

I just want to confirm that this is an issue and no fix is available for this so far.

Regards,
Naresh Rohra.

View 2 Replies View Related

Transact SQL :: Creating A View Using DISTINCT And Not Getting Unique Results?

Sep 21, 2015

I am building a view to be used to drill down into a Lightswitch app I'm building and to drive this I want to use a view based off the selection of that value several other values will be given to the user to choose from related to the first selection. I've created a view using the following statement:

SELECT DISTINCT TOP (100) PERCENT ARSFamily, ARS_Index
FROM dbo.csr_standards_cmsars
ORDER BY ARSFamily

 but the results come back with ALL the records of the source table (509 rows) when there should have only been 29 rows returned (the appropriate number of families or unique groups).  The index is necessary to have Lightswitch use the view as a data source.what I'm doing wrong here?

View 2 Replies View Related

Cannot Copy Field Names In Column Headings From View Results

Jan 8, 2007

When I am using a SQL Query I have an ability to control whether or not I am able to Include the Column Headers when copying or saving results.

The control exists in the Options > Query Results > Results to Grid > Include column headings etc.

My question is how to get this same ability when attempting to copy the results of a VIEW vs. a Query.
The idea is that when I setup a view it€™s a drag/drop type of query building (query building for dummies if you will). Once I have a view and click the Execute icon it will return all the records selected by the View. However, when I click the upper left/top box to select all rows and column and then try to copy/paste the records into Excel all the data copies just fine but the field name/column headers are not there.
How can I get the header fieldname date to copy/paste from View result set that I'm able to copy from a Query result set?
Thank you,
Mike

View 1 Replies View Related

ADO.NET Returns Different Colum Value When Compared To View Results In SQL 2005 Management Studio

Feb 7, 2007

I have a complex view in my sql 2005 database.
The view returns a column that could be null (as the result of a left outer join).
The coulmn that is returned is an integer.
Everything works fine if I run the view from SQL 2005 Management Studio.
My column value is always null if I use ADO.NET's SqlAdapter to return a DataTable.
Has anybody seen this behaviour before?
Any help appreciated.
Regards,
Paul.

View 2 Replies View Related

SQL 2012 :: Displaying Results Between Dates

Aug 6, 2014

I am designing a database to store data from a leak tester.

We want to display the results between dates, I mean, the results of the leaking test are going to be stored as well as the datetime in which they have been performed.

ID (int)
RESULT (float)
TS (datetime)

The query will be, of course:

SELECT * FROM TABLE Where TS BETWEEN DT1 and DT2

This table is growing by 10000 rows a day, it is possible that in a year getting the values between two dates became impossible.

Using a index with a datetime field sounds like a crazy idea.

View 2 Replies View Related

SQL 2012 :: Separating Results From 1 Column?

May 13, 2015

i have written a query I was SO proud of but THEN was told to separate the values out of one column. simple way to do this without having to rewrite the whole query? Will I need to include a Case statement?

Basically the column contains several types of vacation codes which will need to be renamed to 2. So there is leave 1, leave 2, and leave 3 and sick. I will need to rename all leave 1, 2, and 3 to just vacation and leave sick as sick.

View 3 Replies View Related

SQL 2012 :: Pasting Query Results Into XL From SSMS

Mar 13, 2014

Previous to 2012, grid results from SSMS queries pasted into Excel beautifully and were easy to format.in 2008, The results from this query pasted into a spreadsheet with the query contained in a single Excel cell:

(sample - not the whole script)
select top 300
Avg_CPU_Time
,Total_Physical_Reads
,convert(datetime,Last_execution_time) as Timestamp
,Stored_Procedure
,Query_text
from dbadmin.dbo.History_CPU_IO_ByQueryAndSP

This was wonderful. I could deliver to developers wonderfully tidy reports on query resource usage with timestamps along with which stored procedure the queries came from.

Can't do that in SSMS 2012. Try it. It's a disaster. The Query_text, when pasted, spreads across multiple Excel columns, including the ones designated for other data. The result is totally unreadable.how to make the query_text stay in it's own cell? I've tried converting query_text to varchar and ntext. Same results.

View 9 Replies View Related

SQL Server 2012 :: Getting Results From All Tables In Database

Mar 13, 2014

below is my statement to get data from one column (VARCHAR) from table SUPPLY_ITEM_01

SELECT
@@SERVERNAME as ServerName,DB_NAME() AS DatabaseName,
SUM(CASE WHEN CHARINDEX (CHAR(013) , supplydetail) > 0 THEN 1 ELSE 0 END) AS TotalCHAR013,
SUM(CASE WHEN CHARINDEX (CHAR(012), supplydetail ) >0 THEN 1 ELSE 0 END)AS TotalCHAR012,
SUM(CASE WHEN CHARINDEX (CHAR(010), supplydetail ) >0 THEN 1 ELSE 0 END) AS TotalCHAR010,
SUM(CASE WHEN CHARINDEX (CHAR(009),supplydetail ) >0 THEN 1 ELSE 0 END) AS TotalCHAR009
FROM

[code]...

I need to get result from all the tables and all the columns which has bad data including schemaName, table name and column name in result.

View 9 Replies View Related







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