SQL 2005: ISNUMERIC() And Views

Sep 10, 2007

Hello all!

I've wrote a small query for SQL 2005 and it's doesn't seem to work.

I have a table that contains two columns (X and Y), X is an int and Y is an nvarchar(50). I've populated this table with some data where Y contains numbers and some strings (e.g. "1", "2", "foo", etc). I've then got a view which only returns the rows where Y is numeric - now, I then query this table stating I only want numbers greater than 0 (i've casted the column) but this throws an error stating "foo" can't be casted. This is strange because the view doesn't return that.

What's going on? All of this works fine in SQL 2000 but not in SQL 2005 - looks like it's looking at the underlying table rather than the view. Sample code below to help you all out: -

Create Table
============
CREATE TABLE [dbo].[tblTest](
[X] [int] NOT NULL,
[nvarchar](50) NOT NULL
) ON [PRIMARY]


Insert Data
===========
INSERT INTO tblTest(X, Y) VALUES(1, '1')
INSERT INTO tblTest(X, Y) VALUES(1, '2')
INSERT INTO tblTest(X, Y) VALUES(2, 'foo')
INSERT INTO tblTest(X, Y) VALUES(2, 'bar')


Create View
===========
CREATE VIEW [dbo].[vwTest]
AS
SELECT X, Y
FROM dbo.tblTest
WHERE (ISNUMERIC(Y) = 1)


Finally
=======
SELECT X, Y
FROM dbo.vwTest
WHERE (CONVERT(int, Y) >= 0)

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value 'foo' to data type int.




Thanks in advance!

View 10 Replies


ADVERTISEMENT

Bug In ISNUMERIC ?

Apr 13, 2004

strange thing I just ran into, not sure if this is a bug or what ... but pretty annoying.
In MS SQLServer 2000 :

SELECT (ISNUMERIC('0E010101'))

returns "1"

but

SELECT CAST ('0E010101' AS numeric)

returns "Error converting data type varchar to numeric"

any idea?

View 14 Replies View Related

IsNumeric() - It Can Not Be Right?

Mar 27, 2006

hi,

i am migrating data from a legacy system with a not nice front-end.
as a result, i have all sorts of garbage stored on the tables.

i
am trying to convert values from varchar(12) to float, but i have an
error during selecting data that says that data can not be converted
eventhough i am using the ISNUMERIC() function to check.

case when
isNumeric( myCol01 ) = 0 then null
else
convert( float , myCol01 )
end

but my error occours when ISNUMERIC() encounters the value  '.              ' ; that is a dot with spaces after it.

try the expression below;

SELECT

  myValue = '.              '
, is_numeric = ISNUMERIC('.              ')
, converted = CONVERT( FLOAT , '.              ')



has anyone got any idea how to work around this?

nicolas

View 5 Replies View Related

Sum And IsNumeric

Feb 27, 2008

Hi,

I have a table described as follows:

TableA
GrpDate DateTime;
grpMiscError varchar(1);


Ex Data:

2/1/2008 1
2/1/2008 1
2/1/2008 0
2/1/2008 x
2/1/2008 0

The grpMiscError can contain 0, 1 or x only. I need to sum up this column for all the zeros by a particular date.
I have the following but doesn't work:
SELECT
SUM(CASE ISNUMERIC(grpMiscError) WHEN 0 THEN 1 ELSE 0 END)AS MiscError
FROM TableA
WHERE GrpDate = '2/1/2008'

I get back an answer of 1 MiscError instead of 2
What am I doing wrong here?

Thanks,
J

View 6 Replies View Related

IsNumeric Does Not Appear To Work

Feb 5, 2001

Hi all,
I have never seen this problem in SQL Server 7. The isnumeric() returns true for non-numeric data, as show in the following example:

declare @x as varchar(5)

select @x = '00d01'
select isnumeric(@x)

I would expect the isnumeric() function to return false. Can anyone give a reason why this should occur.

Does SQL Server think that this is a hex value and is performing an implicit conversion? If so how horrible...

Nick

View 2 Replies View Related

Isnumeric Function

Mar 4, 2002

The isnumeric function returns 1 in examples where it should not:

select isnumeric('1D9') returns 1.

Can anyone explain this?

View 1 Replies View Related

Isnumeric In SQL SERVER 7

Feb 23, 2005

Hello,

I would like to perform a delete statement on one of my tables.

I have a code column that has data in the form 011-234-12
and at some point in this column the data is like R0 or D1

I want to delete the rows where the code data is R0 or D1, E3, etc...

I would like to know how to create an SQL Command for Sql Server 7 that would delete from Soumission_detail where:

first left char is not Numeric in the code column.

Thanks.

View 4 Replies View Related

ISNUMERIC() In LIKE Statement

Jan 10, 2007

HiHere's the problem:I need to search a postcode database by the first one or two letters.Problems occur for example when i want to search north London postcodes (N) when using:postcode LIKE @postcode + '%' As this picks up everything beginning with N, eg, NG for Nottingham, or NE for Newcastle. So i need a like statement which searches for the first one or two digits followed by a number!I've found the ISNUMERIC() function but not sure what the best way to use it with the like statement - or even if there is a better way altogether - can you use regular expressions in MSSQL?thanks

View 4 Replies View Related

ISNUMERIC Is Sneaky

May 18, 2004

sneaky, sneaky, sneaky
ISNUMERIC returns 1 when the input expression evaluates to a valid integer, floating point number, money or decimal type; otherwise it returns 0. A return value of 1 guarantees that expression can be converted to one of these numeric types.

thanks, but which one??

numeric as far as float is concerned, is not the same thing as numeric as far as money is concerned

create table isnumerics
( id integer not null identity
, txtfld varchar(11)
)

insert into isnumerics (txtfld) values ( '1' )
insert into isnumerics (txtfld) values ( '937' )
insert into isnumerics (txtfld) values ( '937.0' )
insert into isnumerics (txtfld) values ( '$937' )
insert into isnumerics (txtfld) values ( '$937.00' )
insert into isnumerics (txtfld) values ( 'free' )
insert into isnumerics (txtfld) values ( '.50' )
insert into isnumerics (txtfld) values ( '1,000' )
insert into isnumerics (txtfld) values ( '' )

select id
, txtfld
, isnumeric(txtfld)
from isnumerics

111
29371
3937.01
4$9371
5$937.001
6free0
7.501
81,0001
90


select id
, txtfld
, isnumeric(txtfld)
, case when isnumeric(txtfld) = 1
then cast(txtfld as money)
else cast(null as money)
end as case1
from isnumerics

1111.0000
29371937.0000
3937.01937.0000
4$9371937.0000
5$937.001937.0000
6free0
7.501.5000
81,00011000.0000
90

select id
, txtfld
, isnumeric(txtfld)
, case isnumeric(txtfld)
when 1
then cast(txtfld as money)
else cast(null as money)
end as case2
from isnumerics

1111.0000
29371937.0000
3937.01937.0000
4$9371937.0000
5$937.001937.0000
6free0
7.501.5000
81,00011000.0000
90

select id
, txtfld
, isnumeric(txtfld)
, case isnumeric(txtfld)
when 1
then cast(txtfld as float)
else cast(null as float)
end as case2
from isnumerics


1111.0
29371937.0
3937.01937.0

6free0
7.5010.5
the others got "Error converting data type varchar to float"

no, there wasn't a question here, but yes, i'd love to hear your comments

View 6 Replies View Related

Isnumeric Issue

Aug 28, 2007

Hi,

I'm casting a varchar field to a decimal field using the format

CASE ISNUMERIC(GrossMktCapGbp)
WHEN 1 THEN CONVERT(DECIMAL(18,6),GrossMktCapGbp)
ELSE NULL
end

Thinking this would ensure that any spurious rows got set to null.

However I had a problem with some values that were set to '.', it seems that isnumeric thinks these are numbers but casting them to decimal produces an error.

SELECT ISNUMERIC('.')
SELECT CAST('.' AS DECIMAL(18,6))

Should I have been doing something different in my check possibly.




Sean

View 10 Replies View Related

Iif And IsNumeric Functions

Nov 29, 2007

=iif(

IsNumeric(Fields!Accreditation.Value),

Int(Fields!Accreditation.Value),

Fields!Accreditation.Value

)

The above expression seems to work fine if Fields!Accreditation.Value is a number. However, if Fields!Accreditation.Value is not a number, it gives an #Error. Why is the true part evaluated when the expression is false?

View 6 Replies View Related

IsInteger - Replacement For IsNumeric

Dec 13, 2005

Been meaning to post this for a while. It does a very limited job of only allowing [0-9], but could be extended to allow negative numbers, or numeric values that are suitable for numeric types other than INT, but avoiding the pitfalls of IsNumeric() which might allow through data not suitable for some of the numeric datatypes

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[kk_fn_UTIL_IsINT]') AND xtype IN (N'FN', N'IF', N'TF'))
DROP FUNCTION dbo.kk_fn_UTIL_IsINT
GO
CREATE FUNCTION dbo.kk_fn_UTIL_IsINT
(
-- String to be tested - Must only contain [0-9], any spaces are trimmed
@strINTvarchar(8000)
)
RETURNS int-- NULL = Bad INT encountered, else cleanedup INT returned
/* WITH ENCRYPTION */
AS
/*
* kk_fn_UTIL_IsINTCheck that a String is a valid INT
*SELECT dbo.kk_fn_UTIL_IsINT(MyINTColumn)
*IF dbo.kk_fn_UTIL_IsINT(MyINTColumn) IS NULL ... Bad INT
*
* Returns:
*
*int valueValid integer
*NULLBad parameter passed
*
* HISTORY:
*
* 30-Sep-2005 Started
*/
BEGIN

DECLARE@intValueint

SELECT@strINT = LTRIM(RTRIM(@strINT)),
@intValue = CASE WHEN @strINT NOT LIKE '%[^0-9]%'
THEN CONVERT(int, @strINT)
ELSE NULL
END
RETURN @intValue

/** TEST RIG

SELECTdbo.kk_fn_UTIL_IsINT('123'),IsNumeric('123')
SELECTdbo.kk_fn_UTIL_IsINT(' 123 '),IsNumeric(' 123 ')
SELECTdbo.kk_fn_UTIL_IsINT('123.'),IsNumeric('123.')
SELECTdbo.kk_fn_UTIL_IsINT('123e2'),IsNumeric('123e2')
SELECTdbo.kk_fn_UTIL_IsINT('XYZ'),IsNumeric('XYZ')
SELECTdbo.kk_fn_UTIL_IsINT('-123'),IsNumeric('-123')
SELECTdbo.kk_fn_UTIL_IsINT('-'),IsNumeric('-')

**/
--==================== kk_fn_UTIL_IsINT ====================--
END
GO

Kristen

View 15 Replies View Related

ISNUMERIC In Derived Column

Feb 14, 2008

I would like to validate datatype using Derived Column.My data type are such as numeric(X,X),datetime,int, and varchar.How do I do this using Derived Column.Example if row does not qualify as ISNUMERIC()...throw it in ERROR table else send it to SUCCESS table.Any Idea ?

View 4 Replies View Related

Testing For IsNumeric In SSIS

Dec 18, 2007

Hello,
I have searched the forum, and have discovered that the DTS method using IsNumeric to check for numierc values (ActiveX) is not valid in SSIS. Most of what I have seen prescribes using the script component to handle this.

So formerly, I checked to see if a column was numeric. If it was, then I needed to use the numeric value as is, or in some cases, I needed to perform a calculation on the value and use the result. If the value was not numeric, then whatever the value was needed to be changed to zero.

Here is an example of how I would use the current value, or set the value to zero:

If IsNumeric(DTSSource("Col003")) Then DTSDestination("ADepTrnx") = CLng(DTSSource("Col003")) Else DTSDestination("ADepTrnx") = 0 End If

This is an example of how I would use the current value in a calculation, or set the value to zero:

If IsNumeric(DTSSource("Col012")) Then DTSDestination("AlliStdFee") = CLng(DTSSource("Col012"))/100 Else DTSDestination("AlliStdFee") = 0 End If

Does anyone have an example of how I would handle both situations in a script component?

Thank you for your help!

cdun2

View 3 Replies View Related

Interesting IsNumeric Result

Aug 20, 2007

Does anyone else get the following result when running this query?


Select isnumeric('4D7')


-----------

1

(1 row(s) affected)




Does anyone know why this would return true for numeric?

Thanks,

Ray

View 4 Replies View Related

How To Handle ISNUMERIC() Function ?

Aug 31, 2006

I have a task (Derived Column Task) and I want to write something like this :

IsNumeric(aColumnOfString) == true ? "All numbers" : "there are some characters"

Here aColumnOfString can be something like "123a5" or 12345". I do not want to simply check if the left-most character is a number or not. I want to check the entire expression and return me a TRUE or false.



A TRUE is returned if the entire expression contains ONLY numbers, and FALSE otherwise.

I read some posting using regular expression. But that is not a solution for this situation.

Anyone knows how to accomplish this, please help!

View 3 Replies View Related

Using IsNumeric Within A Case Statement (within An Insert)

Mar 25, 2003

Hi - Please excuse me if this is really simple, but I'm fairly new to this lark.

My (made up) code is below... I'd be grateful for any pointers.

insert into [tblInvoices]
(full_period,
supplier_no,
account_code,
tran_amount,
function)
select
full_period,
supplier_no,
account_code,
tran_amount
case
when substring(account_code,1,2) = 'FY' then '-'
when isNumeric(account_code) then left(account_code, 2)
when not isNumeric(substring(account_code,1,2)) then left(account_code, 1)
else 'oops'
end as function,
from
tblLoadMSV900_i
end

Is this even close?

I'm using a stored proc to insert the data from tblLoadMSV900_i into tblInvoices and at the same time insert some data into the function field.

In plain english I want make sure that:
If the first 2 chars of account_code are 'FY' then function='-',
If the first char of account_code is numeric then function=left(account_code, 2),
If the the first char is not numeric (and if first two chars are not 'FY' i.e. first char could be 'F') then function=left(account_code, 1)

And there's plenty more where this came from! But if I can crack this with your help then I should have a better idea about the rest of the proc.

Thanks
Sara

View 2 Replies View Related

Are Embedded Views (Views Within Views...) Evil And If So Why?

Apr 3, 2006

Fellow database developers,I would like to draw on your experience with views. I have a databasethat includes many views. Sometimes, views contains other views, andthose views in turn may contain views. In fact, I have some views inmy database that are a product of nested views of up to 6 levels deep!The reason we did this was.1. Object-oriented in nature. Makes it easy to work with them.2. Changing an underlying view (adding new fields, removing etc),automatically the higher up views inherit this new information. Thismake maintenance very easy.3. These nested views are only ever used for the reporting side of ourapplication, not for the day-to-day database use by the application.We use Crystal Reports and Crystal is smart enough (can't believe Ijust said that about Crystal) to only pull back the fields that arebeing accessed by the report. In other words, Crystal will issue aSelect field1, field2, field3 from ReportingView Where .... eventhough "ReportingView" contains a long list of fields.Problems I can see.1. Parent views generally use "Select * From childview". This meansthat we have to execute a "sp_refreshview" command against all viewswhenever child views are altered.2. Parent views return a lot of information that isn't necessarilyused.3. Makes it harder to track down exactly where the information iscoming from. You have to drill right through to the child view to seethe raw table joins etc.Does anyone have any comments on this database design? I would love tohear your opinions and tales from the trenches.Best regards,Rod.

View 15 Replies View Related

How To Use Views In ASP.NET 2005

May 9, 2007

Hi,   I have created some views of the select join query in sql server 2005.   I want to make use of this views with the asp.net 2005 with C# code.   I m using SQLDATASOURCE to retrieve data from sqlserver.   Can anyone help me how to write in C#VIEW SELECT CAST(LEFT(SalesReturnDate, 11) AS datetime) AS Date, SUM(TotalAmount) AS Salesreturn
FROM dbo.dfh_SalesReturnHeader
GROUP BY CAST(LEFT(SalesReturnDate, 11) AS datetime) This is the sample view how to connect it with asp.net C#,sqldatsource of 2005Thanxs in adv.  

View 1 Replies View Related

T-SQL - Check For Decimal?? Like ISNULL, ISDATE, ISNUMERIC, Etc.

Apr 14, 2008

There is a MSSQL function that check the value. Like ISNULL(), ISDATE() and ISNUMERIC(). I don't see a function that check for decimal. If there isn't any then is there an user-defined function for it? I need to be able to validate the string value for decimal before it get assigned to a decimal datatype or T-SQL will run into an error.

I'm using MS-SQL 2000...

Thanks...

View 3 Replies View Related

Transact SQL :: Using CAST (column AS BIGINT) And ISNUMERIC

Aug 27, 2015

I found this to work:

SELECT uri, evFieldUri, evFieldVal
, CAST(evFieldVal
AS BIGINT)
FROM TSEXFIELDV

[Code] ....

It Returns:

uri          
evFieldUri          
evFieldVal          
(No column name)
224016  3267      
+000089243829 89243829
224019  2717      
+000089243825 89243825
224472  3333      
+000000000000000000000017     17
225052  3267      
+000089243829 89243829
225055  2717      
+000089243825 89243825

So, then I went back to:

SELECT uri, evFieldUri, evFieldVal
, CAST(evFieldVal
AS BIGINT)
FROM TSEXFIELDV

[Code] ....

And it returns this error:

Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to bigint.

So, I tried again, and this worked…

SELECT uri, evFieldUri, evFieldVal,CAST(evFieldVal
AS BIGINT),
ISNUMERIC(evFieldVal)
FROM TSEXFIELDV WHERE URI
> 0 AND evFieldUri
IN ( SELECT URI
FROM TSEXFIELD WHERE exFieldFormat
IN (1,11))

I logged out and came back and tried again, and it still worked. So then I tried…

SELECT uri, evFieldUri, evFieldVal,CAST(evFieldVal
AS BIGINT)
FROM TSEXFIELDV
WHERE URI
> 0

[Code] ...

And it fails.

View 5 Replies View Related

Views Problem In SQL 2005

Jan 17, 2008

So, my SQL server was recently upgraded from SQL 2000 to SQL 2005. Everything seemed to go smoothly and look good, but now it seems that a view that had been created in SQL2000 isn't working as it should, and I can't for the life of me figure out why.
Here's the deal - I have a phone/email directory page & database that I maintain, and this view is supposed to pull data from 2 different tables and combine it into one view - specifically matching people with their associated organizations (and pulling the needed data on each organization), and then this should be sorted first by the OrgID, and then by the PersonID. The OrgID sort is working just fine, but for some reason it's not necessarily then sorting by PersonID anymore. I tried creating a whole new view using the designer in SQL Server Management Studio, but it has the same problem.
I'm including the queries for each of the views below - any help would be much appreciated!
Thanks
Kaiti
Original View:USE [DirectorySQL]GO/****** Object:  View [dbo].[OrgView]    Script Date: 01/17/2008 12:07:56 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER VIEW [dbo].[OrgView]ASSELECT     TOP 100 PERCENT *FROM         dbo.OrgList INNER JOIN                      dbo.Merge ON dbo.OrgList.OrgID = dbo.Merge.MergeOrgIDORDER BY dbo.OrgList.OrgName, dbo.Merge.MergePersonID
New View:USE [DirectorySQL]GO/****** Object:  View [dbo].[NewOrgView]    Script Date: 01/17/2008 12:08:14 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER VIEW [dbo].[NewOrgView]ASSELECT     TOP (100) PERCENT dbo.Merge.MergePersonID, dbo.Merge.MergeOrgID, dbo.Merge.MergeTitle, dbo.OrgList.OrgID, dbo.OrgList.OrgName,                       dbo.OrgList.OrgType, dbo.OrgList.OrgAssociation, dbo.OrgList.OrgOffice, dbo.OrgList.OrgCampusMail, dbo.OrgList.OrgFax, dbo.OrgList.OrgInfoPhone,                       dbo.OrgList.OrgInfoEmailFROM         dbo.Merge INNER JOIN                      dbo.OrgList ON dbo.Merge.MergeOrgID = dbo.OrgList.OrgIDORDER BY dbo.OrgList.OrgID, dbo.Merge.MergePersonID

View 6 Replies View Related

Creating Views In SQL 2005

Jun 17, 2008

can anyone tell me why when I create a view if I do this in my select statement "CAST(CrewNo AS char(10)) AS CrewNo" and then save the view the above CAST statement will be changed to this "CAST(CrewNo AS char(10)) AS Expr1". After I have it saved and then go back and change it back to "CAST(CrewNo AS char(10)) AS CrewNo" it will stay that way. Just looking for a reason why this is happening as I don't know if I'm doing something wrong or not.

View 2 Replies View Related

SQL Server 2005 Replication And Views

Feb 24, 2006

Hi,

I read that views can't be published with SQL Server 2005 replication. Is this planned for the future? If not what alternatives are there for this?

Simple collecting the data needed in a new table ain't a solution for us (memory consuming). And joining the data on the PPC ain't a good solution either (memory and time consuming). We only want to pull the data.

Greets,

Ivo Klerkx

View 3 Replies View Related

2005 Replication With SCHEMABINDING Subscriber Views

Dec 6, 2007

Hi Folks Is there an easy way around this ? One Way Transactional Rep Subscriber needs SCHEMABINDING on the majority of their Views (require View Indexes) which read from Replicated Tables. Main table has 4 Million Rows ReInitialize Subscription Errors with Cannot Drop Table because it is being referenced By Object ..... [schemaBound View] GW

View 6 Replies View Related

Sql Server 2005 Questions Regarding Editing Views

Jun 21, 2006

Previously in Sql Server 2000, we would be in enterprise manager, you'ddouble click on a view, and a nice little dialog box opened with the t-sqlstatetments, there was also a check sql syntax and apply and cancel buttons.Not exactly query anaylizer, just a quick lightweight dialog box. Is thisfeature still around? Seems like I have to go into the query anaylizer likemode to edit a view now. I am a total newbie to version 2005. Are there anyoptions I can set to make it behave the old way? All feedback isappreciated.TIA,~CK

View 2 Replies View Related

SQL Svr 2005 - Use Same Stored Proc && Views For 2 Databases?

Jan 10, 2007

I am moving a fairly large app from Access 2003 to C#/SQL Server 2005.

The app has one front end mde, but it has two backend data mdbs, one is used in the US and one in the UK.

The two backend mdb's are identical in structure, but of course the data is different. There are 150 tables or so, and we plan to maintain separate databases after the upgrade.

Now, of course, all of the queries are in the front end, the backend db's contain only tables.

In the new world, I do not want to have to maintain the same views and stored procs in two different SQL Server databases.

Is there a way to have all views and stored procs in one database, but have them draw on the data in the two other databases. There must should be a way to deal with this scenario in SQL Server.

Many thanks
Mike Thomas

View 5 Replies View Related

Get The List Of Catalog Views In SQL Server 2005

Oct 10, 2006

How to get the list of catalog views sys.* (sys.objects, sys.columns ....) in sql server 2005

select * from sys.objects where objectproperty(object_id, 'IsSystemTable') = 1

did not return the list as I've expected

thanks

View 4 Replies View Related

Does Sql Server 2005 Compact 3.5 Support Views?

Feb 29, 2008

I think I read somewhere that sql server 2005 Compact Edition (3.1) does not support views. Does anyone know if views were added to 3.5?

View 3 Replies View Related

SQL 2005 Breaks Writeable Multi-table Views

Sep 25, 2006

Hi,

I have some simple views that bind to an Access forms for use in the detail side of Master/Detail forms.

The views are of the style:

SELECT *.OrderDetails, Products.TotalUnitsInStock AS UsefulReferenceInfo

FROM OrderDetails LEFT OUTER JOIN Products ON ..........

Using a database in SQL 2000, opening the view to directly insert values into the OrderDetails columns works perfectly, and Access correctly determines that there is an IDENTITY column that is the Primary Key. Insert works perfectly, form work perfectly.

Using the same SQL script to build a database in SQL 2005 the view doesn't detect that the column is an IDENTITY column so any attempt to insert data fails with the error "Invalid input parameter values. Check the status values for detail." Insert fails, form also doesn't work.



I have tested this in Access 2002, 2003 and 2007 B2TR and all give the same results so it seems to be a breaking change in SQL 2005.

It is easy to see when there is going to be trouble because the tell-tale '(Auto Number)' or more recently '(New)' text is missing from the appropriate identity column.

This is fairly inconvenient and breaks quite a lot of my Master/detail forms that use this design pattern.

Can anybody from the SQL team help shed some light on this for my.

Cheers Simon

View 11 Replies View Related

Large Views Vs Multiple Small Views

Sep 6, 2007

Which is more efficient? One large view that joins >=10 tables, or a few smaller views that join only the tables needed for individual pages?

View 1 Replies View Related

Strange Exceptions With Views Usings Casts On 2005 (worked Fine On Sql2k)

Apr 3, 2007

I have views that cast the data into data types.



On 2005 when retrieving the views using a where clause i get errors. I have put together an example below that illustrates the error.



CREATE TABLE TestData ( Id VARCHAR(10), [Description] VARCHAR(20), [Type] INT)

CREATE TABLE TestTypeLookup( [Type] INT, [Description] VARCHAR(20))

GO

INSERT INTO TestTypeLookup VALUES (1, 'Type 1')

INSERT INTO TestTypeLookup VALUES (2, 'Type 2')

INSERT INTO TestData VALUES ('AA', 'Description for AA', 1)

INSERT INTO TestData VALUES ('10', 'Description for 10', 2)

INSERT INTO TestData VALUES ('20', 'Description for 20', 2)

GO

CREATE VIEW TestView AS

SELECT TOP 100 PERCENT CAST(Id AS INT) Id, [Description]

FROM TestData

WHERE [Type] = (SELECT TOP 1 [Type] FROM TestTypeLookup WHERE [Description] = 'Type 2')

ORDER BY CAST(Id AS INT)

GO

SELECT * FROM TestView WHERE Id = 10

GO

DROP VIEW TestView

DROP TABLE TestData

DROP TABLE TestTypeLookup

GO

View 11 Replies View Related

Distributed Query From SS 2000 To Access Catalog Views On SS 2005 Via Linked Server

Aug 24, 2006

I am trying to write some admin only procedures which will collect information to one of my development server from other production and development servers.
 
I have created linked servers to access these other servers on the development server. This development server is SQL Server 2000 EE. Other servers which I want to access are 2000 and 2005 (vaious editions)
 
E.g I have another development server called PRODTEST which is SQL Server 2005 and on the development server I have created a linked server pointing to PRODTEST called TESTLINKSRV. I want to access new object catalog view (as I do not want to use sysobjects)
 
When I run the following query
 
SELECT * FROM [TESTLINKSRV].[DBNAME].[sys].[objects]
 
I get following error,
 
OLE DB error trace [Non-interface error:  OLE DB provider does not contain the table: ProviderName=' TESTLINKSRV ', TableName='" DBNAME "."sys"."objects"'].
 
Msg 7314, Level 16, State 1, Line 1
 
OLE DB provider ' TESTLINKSRV ' does not contain table '"DBNAME"."sys"."objects"'.  The table either does not exist or the current user does not have permissions on that table.
 
So I try this query
 
SELECT * FROM [TESTLINKSRV].[DBNAME].[sys.objects]
 
and I get following error
 
Msg 208, Level 16, State 1, Line 1
 
Invalid object name TESTLINKSRV.DBNAME.sys.objects'.
 
So bottom line is how do I access catalog views on a 2005 server from a 2000 server using linked server?
 
I hope someone understands what I am trying to achieve. Please let me know what is it that I am doing wrong.
Thank you

View 5 Replies View Related







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