Query To Find The Indexed Columns

May 30, 2007

Dear Experts, i need one query to find all the indexed columns with table names ,column names and type of indexes....

i'm trying with sysindexes, but i was unable to finish it....i'm not clear about keys column in sysindexes...

please guide me.

thank you very much

View 12 Replies


ADVERTISEMENT

Query To Find Duplicate (paired) Columns

May 28, 2012

I have the following table:

f_namef_countryf_ID
ABCUS123
DEFGB123
ABCUS456
GHIGB789
etc.

I need to run a query to discover all instances where a f_name and f_country pair exists for more than one f_ID. ABC/US is one such example; IDs 123 and 456 have this pair.

View 7 Replies View Related

Smalldatetime In Indexed Computed Columns

Nov 13, 2001

i have a table containing the column "current month" and "current day" as smallint which contains the number of months since 1900-01-01 and the day of this month. now i want to trnslate this column in a smalldatetime ( not datetime !) value using a computed column and then create an index on that column.

the formula should be:
dateadd(d,[current day]-1,
dateadd(m,[current month],convert(smalldatetime,'1900-01-01'))
)

trying to create an index on this column results in an error message saying
that the formula is nondeterministic or imprecise

removing the convert statement leaving only the date results in a column of type datetime and creating the index works fine


replacing convert(smalldatetime,'1900-01-01') with a column name which has the type smalldatetime also allows to create an index but thats not what i want to do.

it seems that sql2000 thinks a convert from a string to a date is nondeterministic. Is there any possibility to create a const of type smalldatetime without using convert?

Any idea?

(besides this, datediff(d,'yyyy-mm-dd',anydate) is nondeterministic but datediff(d,dateadd(d,0,'yyyy-mm-dd'),anydate) is deterministic. strange...)





and

View 1 Replies View Related

OLE DB ARITHABORT Error With Indexed Computed Columns

Oct 31, 2002

Instead of using Full-Text indices, which I don't like to manage, we've tried to use seperate tables that contain recordID, the word, a count of the word in the parent field and computed column which is the CHECKSUM() of the word column. I indexed the checksum column with a clustered index.

Works great in Query Analyser. But when the ASP page calls it, I get this message:

Microsoft OLE DB Provider for SQL Server (0x80040E14)
INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'.

Same for updates and deletes. The question is how should these SET settings be done? Any ideas would be greatly welcomed.

Thanks
Jason

View 3 Replies View Related

Transact SQL :: Returning Non Indexed Records From Sorted Table - Speed Same As Indexed?

Dec 1, 2015

I have created a table from another table where I specified that one of the fields, an number field,  is sorted in ascending order and have NOT specified that it is to be an indexed field and there are 10 million records, from 1 to 10,000,000 exactly.

Now, if I query that table, asking to return records 1-1,000 from that non indexed number field that I sorted in ascending order (where number field <= 1,000) , will it run as fast as if it were indexed?

In other words, does SQL know somehow that these records are sorted in ascending order and so will not do a full table scan, stopping at 1,000 to return my data set?

Or is there no way for SQL to know this and only specifying an indexed field allows SQL to know that its in some order and so it doesn't have to do the full scan?

View 15 Replies View Related

Indexed View Not Used By The Query Optimizer

Aug 20, 2007

Hello All,
I have a series of Stored Procedure that has a query taking a join of 5 tables. These tables are quiet large with couple of them having around 10 million rows. As this is a DSS application having periodic data loads, I thought of creating Indexed View on top of these tables. Now the problem is that the Indexed View is not directly used by the optimizer. I need to change my queries and put a WITH (NOEXPAND) query hint to make sure the indexed views are used. This is inspite getting dramatic improvement in the query timings (from 64 secs down to 3 secs) after using the Indexed Views. I would like to know what can be the possible reason for the optimizer not using the Indexed View by itself. Is it because my Indexed View caters to multiple queries or I am missing out on something basic.

Thanks in Advance,
Mitesh Shah

View 4 Replies View Related

SQL Server 2012 :: Query To Search Full-text Indexed Table And Return Results

Apr 19, 2014

I have written this sample query to search a full-text indexed table and return the results. If the word occurs more than once I want it to return as a new record and the results show a short summary of the location. I was using 'like', but the full table scans were really slowing it down. Can performance be improved for the following (The results returned by my query are accurate)

Query

DECLARE @searchString nvarchar(255);
DECLARE @searchStringWild nvarchar(275);

SET @searchString = 'first';
SET @searchStringWild = UPPER('"' +@searchString+ '*"');

SELECT id, '...' + SUBSTRING(searchResults.MatchedCell, searchResults.StartPosition, searchResults.EndPosition - searchResults.StartPosition) + '...' as Result

[Code] ....

View 2 Replies View Related

How To Find No. Of Columns ?????

May 5, 2008

Hi is there any way to find no. of columns in a database table
like we can do that in Oracle by typing DESC tablename

San

View 5 Replies View Related

Find Max Values From 3 Different Columns?

Mar 9, 2008

Hi I want to find 3 different columns maximum values in one shot. Like I tried to use a reader to go through results but it kept coming back with index out of bounds. Right now to get it to work I got to use a ExecuteScalar() get the first columns max value and then open the connection again(since it seems after ExecuteScalar() it closes the connection) and then do the ExecuteScalar() again. Open the connection again and do the ExecuteScalar() again. Theres got to be a better way of doing this. 

View 3 Replies View Related

Find Lowest Value In 3 Columns

Jun 2, 2008

Im having trouble finding a solution to comparing columns to find the lowest value.

Example

Row 1

COL 1 = 10
COL 2 = 20
COL 3 = 60
COL 4 = 5
COL 5 = 35

I would want to return 5.

I tried to write a case statement such as below but am unable to use Logical Operators.

WHEN C1 <= C2 and C1<= C3 THEN C1
WHEN C2 <= C3 THEN C2
ELSE C3



any help would be great.

Thanks,
Nick

View 1 Replies View Related

Find Out Similar Columns

Apr 19, 2007

i like to write a sql query to find out similar columns in different tables.

i have something like this. but my logic is wrong.

select *
from information_schema.columns a
join information_schema.columns b
on a.column_name = b.column_name
and a.table_name <> b.table_name

View 1 Replies View Related

How Can I Find All Columns, That The Key Is Made Of?

Nov 27, 2006

In every database we have 'sysobjects' table storing names of all objects(including all keys)  in our data base. How can I find all columns, that the key is made of? Sorry about my english :-/

View 1 Replies View Related

To Find Ratio Between Two Columns

Oct 16, 2007

Can anyone pls help me to solve my problem in SSRS. Also I wanted to plot the 'Ratio' in to a chart against the 'Year'.

The scenario is:

Year Amount_A Amount_B Ratio(Amount_A/Amount_B)
05 x y x/y
06 a b a/b
07 m n m/n

Its very needy.

View 9 Replies View Related

Cannot Find Columns From A Stored Procedure...

Jul 21, 2007

I have an application that I inherited, and I have a annoying problem.  We're using stored procedures to return most of our data, and occasionally we receive errors stating that a particular column cannot be found in the resulting data table.  When I run the stored procedure against SQL Server I receive the expected output.  What would make this random act happen, any ideas?
Also, I keep receiving errors stating that a connection is already open and needs to be closed before an action to the database is performed.  I'm explicitly closing each connection in a finally block for every method in my data access code, so a connection should always be closed, right?

View 3 Replies View Related

Find Out Which Table Columns Data Comes From

May 9, 2008

TableName: EmployeeCloumns:     EmployeeID                  EmployeeName                  If I do "Select * From Employee", is there a way to do something like this...
Loop through each result   IterateThroughControls.ID &= dbTable & dbColumnName & "<br />"EndSo that the end result would assign ID values...EmployeeEmployeeIDEmployeeEmployeeName

View 5 Replies View Related

Find The Smallest Number In Two Columns Was: How Do I Do This ?

Jun 15, 2005

Hi,
I have a sql query which gives me the result set with lots of columns and rows.

a b c allocated unallocated
- ------ 75458702 0484095809
------- 534534 8743857
------- 953459034 90584395

i have to find of which is the smallest number in both allocated and unallocated columns -
here in this case
it would be 534534.
how do i do this ?

Thanks

View 1 Replies View Related

Find Columns Which Execute Updatetriggers

Oct 9, 2006

Hello,

I want to find the columns which execute updatetriggers. Is there in sqlserver a way to find out?

In Oracle you can say:

SELECTCOLUMN_NAME
FROMDBA_TRIGGER_COLS
WHERETRIGGER_OWNER = 'MyOwner'
AND TRIGGER_NAME = 'JobUpdate'
AND TABLE_NAME = 'Job'
AND COLUMN_LIST = 'YES'

I tried: EXEC sp_depends "dba.JobUpdate".

This says nothing about the updatecolumns.

Can anybody help?

thanx and greetz

C Dunnink
The Netherlands

View 3 Replies View Related

Find Records Where There Is Difference Between 2 Columns

Jan 24, 2014

I am trying to produce a report in Application express. I want to find records where there is a difference between 2 columns eg

Debt_amount - billed_amount

where debt >billed amount

I only want to see records where the debt is more than the amount billed

View 1 Replies View Related

How To Find Ntext Datatype Columns?

May 30, 2007

Dear experts,
how can i find the ntext datatype columns in a database?

please guide me

View 4 Replies View Related

Trying To Find A Match In Computed Columns

May 26, 2006

I need to create an function similar to the "MATCH" function in Excelthat evaluates a number within a set of numbers and returns whetherthere is a match. I have put the example of what I see in excel in thecheck column. The "0" answer in the result column is in the fourthaccount in the list. Somehow I need to loop through the accountscomparing the result to the total and indicate a match in the checkcolumn. It wouldn't even need to tell me the row number; it could be a0 or 1.account total result check123770266.84124.2112377026131.050 412377026164.38-33.33123770260131.051237702678.7152.3412377167-31.34221.891237716731.34159.211237716738.55152 51237716731.34159.211237716715238.5512377167490.91-300.36123771670190.55123771670190.5512377167-31.3443.341237716731.34-19.341237716738.55-26.551237716731.34-19.3412377167152-14012377167490.91-478.9112377167012123771670121237736347.058412377363131.05012377363-45.38176.4312377363-47.05178.11237736347.0484.0112377363-47.04178.091237736347.058412377363541.11-410.06123773630131.0512377363672.15-541.11237750737.64152.91

View 3 Replies View Related

Find Out The Columns Should Be Referred Through Foreign Key

Aug 2, 2007

For example if we clearly define a foreign key in the master and child table as following script -

CREATE TABLE master(pkey int PRIMARY KEY, data varchar(10))
GO
CREATE TABLE child (fkey int CONSTRAINT fk_master_child
FOREIGN KEY (fkey) REFERENCES master(pkey))


We can find out the two tables reference relationship by looking at INFORMATION_SCHEMA tables.

However, if the two tables are created in this way €“


CREATE TABLE master(pkey int PRIMARY KEY, data varchar(10))
GO
CREATE TABLE child (fkey int)


Does any one know how to programming verify the actual reference relationship exists between pkey and fkey in these two tables?


Thanks

View 1 Replies View Related

How Do I Find IDENTITY Columns On Table Using T-SQL

Mar 23, 2006

Is there a query I can write against an INFORMATION_SCHEMA or against the system tables to determine if a column is an identity column?

View 8 Replies View Related

Find The Greatest Of Three Columns Per Each Row And Display

Nov 15, 2006

Hi,

i have a problem where in i have to display the greatest marks scored by each student.

How can i do this?? Is there any built in TSQL function.

Rgds..,

Aazad

View 4 Replies View Related

Find All Columns That Have Identity Property

Mar 19, 2008



How do i Find all Columns that have Identity Property in a database. That is i will like to know all columns in a database that are identity columns.

I am using SQL Server 2005. Thanks

View 4 Replies View Related

Transact SQL :: Find Max Of 2 Columns In One Table?

Jul 23, 2015

I am having trouble trying to find the max of 2 columns in one table. I've tried using a common table expression and a subquery, but can't seem to get the correct results. I want to get the max from refnum, then the max "number" associated with that max refnum along with the date and decision

Table
IDCustomerRefnumnumberdate decision
16511114/17/2015Approved
16521125/1/2015Declined
16531216/10/2015Approved
16542116/15/2015Tentative

Expected

Customer 1 had a max of refnum of 2 and 1st one on number

IDCustomerRefnumnumberdate decision
16531216/10/2015Approved
16542116/15/2015Tentative

View 21 Replies View Related

How To Find Out Missing Columns Between Tables

Apr 21, 2015

We are trying to find out the difference between tables in CUSTOMER database and CUSTOMER_coded database. The goal is to find out if there are any columns missing in each table of CUSTOMER_coded database.

We need the list of tables in CUSTOMER_coded database that misses some column compare to its peer in CUSTOMER database (list of columns being missing also).

I googled, but I get only all the columns in tables of database.

I need missing columns of all the tables when we compare these 2 databases( CUSTOMER and CUSTOMER_coded  databases).

View 8 Replies View Related

SQL 2012 :: How To Find Columns That Have Default Constraints

Oct 22, 2015

CREATE TABLE XYZ
(
ID int DEFAULT 5000,
NAME VARCHAR(100)
)

I have many tables that have many columns with default values

Is there a way to get a listing of

TAB_NAME, COL_NAME, Data_type, Default_Value

View 2 Replies View Related

Compare 2 Rows To Find The Difference In Columns?

Aug 14, 2014

How would I compare 2 rows to find the difference in the columns?

Example:
ID Column1 Column2 Column3
1 Text1 Text4
2 Text1 Text2 Text3

Result:
Column1: Text2 New
Column3: Text4 Old Text3 New

View 6 Replies View Related

How Do I Find Indexes Of The Columns In SQL Server 2000???

Nov 10, 2006

How do i find indexes of the columns of all the tables of thedatbase...........most importantly in SQL server 2000Thanks a lot

View 3 Replies View Related

SQL Search :: How To Find What Are All Columns Used In A Store Procedure

Nov 23, 2015

I would like to know all the columns used in a store procedures.I have used dynamic sql to create these procedures .

View 4 Replies View Related

SELECT Query - Different Columns/Number Of Columns In Condition

Sep 10, 2007

I am working on a Statistical Reporting system where:


Data Repository: SQL Server 2005
Business Logic Tier: Views, User Defined Functions, Stored Procedures
Data Access Tier: Stored Procedures
Presentation Tier: Reporting ServicesThe end user will be able to slice & dice the data for the report by


different organizational hierarchies
different number of layers within a hierarchy
select a organization or select All of the organizations with the organizational hierarchy
combinations of selection criteria, where this selection criteria is independent of each other, and also differeBelow is an example of 2 Organizational Hierarchies:
Hierarchy 1


Country -> Work Group -> Project Team (Project Team within Work Group within Country)
Hierarchy 2


Client -> Contract -> Project (Project within Contract within Client)Based on 2 different Hierarchies from above - here are a couple of use cases:


Country = "USA", Work Group = "Network Infrastructure", Project Team = all teams
Country = "USA", Work Group = all work groups

Client = "Client A", Contract = "2007-2008 Maint", Project = "Accounts Payable Maintenance"
Client = "Client A", Contract = "2007-2008 Maint", Project = all
Client = "Client A", Contract = allI am totally stuck on:


How to implement the data interface (Stored Procs) to the Reports
Implement the business logic to handle the different hierarchies & different number of levelsI did get help earlier in this forum for how to handle a parameter having a specific value or NULL value (to select "all")
(WorkGroup = @argWorkGroup OR @argWorkGrop is NULL)

Any Ideas? Should I be doing this in SQL Statements or should I be looking to use Analysis Services.

Thanks for all your help!

View 1 Replies View Related

Find How Long Items Open Using Date Columns

Mar 11, 2013

I have a sample view with some dates. How would you find the numbers of items open per month. Say between OpenDate and CloseDate I want to find how many were open for January, February,?

Here is a sample table with the data

Code:
CREATE TABLE [dbo].[TestDate](
[ItemTitle] [nvarchar](50) NULL,
[ItemAttachAssignDate] [date] NULL,
[ItemDetachConcludeDate] [date] NULL,
[Status] [nvarchar](50) NULL,
[FullName] [nvarchar](100) NULL,
[OpenDate] [date] NULL,
[CloseDate] [date] NULL
) ON [PRIMARY]
GO

Code:
INSERT INTO [TestDate]([ItemAttachAssignDate], [ItemDetachConcludeDate], [Status], [FullName], [OpenDate], [CloseDate])
VALUES('2013-02-18 00:00:00', '2013-02-19 00:00:00', 'Done', 'Jeff Hunter ', '2013-02-18 00:00:00', '2013-02-19 00:00:00');
INSERT INTO [TestDate]([ItemAttachAssignDate], [ItemDetachConcludeDate], [Status], [FullName], [OpenDate], [CloseDate])
VALUES('2012-10-15 00:00:00', '2013-02-05 00:00:00', 'Done', 'Tommy Johnson', '2013-01-22 00:00:00', '2013-01-28 00:00:00');

[Code] .....

View 2 Replies View Related

SQL 2012 :: How To Find Unique Rows Considering Only Specific Columns

Apr 18, 2014

write a query which retrieves only unique rows excluding some columns.

IdStatusmanager Team Comments Proj number Date
19391New XUnassigned One 3732.0 16-Apr-14
19392Can YCustomer Two 3732.0 17-Apr-14
19393Can YCustomer Two 3732.0 17-Apr-14
19394Can YCustomer One 3732.0 18-Apr-14
19395New YCustomer One 3732.0 19-Apr-14
19396New YCustomer One 3732.0 21-Apr-14
19397New ZCustomer One 3732.0 20-Apr-14

In the above table project number and id shouldn't be considered and I should get the unique rows considering rest of columns and sorted based on date. Expected result is

IdStatusmanager Team Comments Proj number Date
19391New XUnassigned One 3732.0 16-Apr-14
19392Can YCustomer Two 3732.0 17-Apr-14
19394Can YCustomer One 3732.0 18-Apr-14
19395New YCustomer One 3732.0 19-Apr-14
19397New ZCustomer One 3732.0 20-Apr-14
19396New YCustomer One 3732.0 21-Apr-14

View 4 Replies View Related







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