Shifted Data Within A View

Aug 28, 2001

I created a view of a table like the following:

create view SomeView
as
select * from SomeTable
where SomeField > 0

I later modified the table to include more fields INTERSPERSED among the previous ones. I noticed that if I didn't recreate the view, the data was shifted if I used a select statement to query the view. I had dates associated with field names where there should be varchars, FirstNames became addresses, etc. Without naming each field in the select statement, does anyone know of a better way to create a view so that you don't have to remember which views do a "select *"?

View 1 Replies


ADVERTISEMENT

Shifted Cells In Excel Export

Mar 25, 2008

Hi,

I created a report in list view (I have to use a subreport in it) and when I export it to excel the cells are shifted even in the header. The html is ok - the problem is only with export.

like this:


Title First Name Last Name Address


Mr John Smith Peartree Str.

I tried to fix the size and location on every cells, but this does'n work in export. Some of the cells drop at the next row and some of they are merged. I was able to receive some good export - but only with a lot of attempts of cells resizing.
Is there any way to avoid this shifting?

View 5 Replies View Related

Transact SQL :: Key And Indexes On Two Column Data Table Or Parsed View (Large String Of Data And Filename)

Oct 4, 2015

I am studying indexes and keys. I have a table that has a fixed width of data to be loaded in the first column which is parsed in a view based on data types within the fixed width specifications.

Example column A:
(name phone house cost of house,zipcodecountystatecountry)
-a view will later split this large varchar string based 
column b: is the source filename of the data load (varchar 256)
....

a. would there be a benefit of adding a clustered or nonclustered index (if so which/point in direction on why)

b. is there benefit of making one of these two columns a primary key (millions of records) or for adding a 3rd new column as a pk?

c. view: this parses the data in column a so it ends up looking more like "name phone house cost of house zipcode county state country" each having their own column.

-any pros/cons of adding indexes (if so which) to the view instead of the tables or both for once the data is parsed?

View 4 Replies View Related

How Can I Return Data From A Database And Fill A Data Grid View?

May 2, 2007

Hi ! I have a textbox and a Search button. When the user inputs a value and press the button, i  want a datagrid to be filled.
The following code runs:
Dim connect As New Data.SqlClient.SqlConnection( _
"Server=SrvnameSQLEXPRESS;Integrated Security=True; UID= ;password= ; database=dtbsname")
connect.Open()
Dim cmd As New SqlCommand
Dim valor As New SqlParameter("@valor", SqlDbType.VarChar, 50)
cmd.CommandText = "Ver_Contactos_Reducido"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = connect
cmd.Parameters.Add(valor)
cmd.Parameters("@valor").Value = texto
Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New System.Data.DataSet()
adapter.Fill(ds)
GridViewContactos.DataSource = ds
GridViewContactos.DataBind()
connect.Close()
I drag a datagrid on the page and only changed its Id.
Into the SQL database the stored procedure is the following:
ALTER PROCEDURE [dbo].[Ver_Contactos_Reducido]
(@Valor VARCHAR(100))
AS
BEGIN
SET NOCOUNT ON;
SELECT NombreRazonSocial, Nombre, Apellido,TelefonoLaboral,
Interno, TelefonoCelular, Email1, Organizacion
FROM CONTACTOS
WHERE NombreRazonSocial = @Valor OR Nombre = @Valor OR Apellido = @Valor OR  TelefonoLaboral = @Valor OR Interno = @Valor OR
TelefonoCelular =@Valor OR Email1 = @Valor OR Organizacion= @Valor
END
When i run the page i can't see the datagrid, and after i enter a text and press the button, nothing happens. What am i doing wrong??
Thks!!

View 2 Replies View Related

Data Access :: Query On View To Get A Single Batched Data

Nov 25, 2015

I have a view that  give me the data of all the batched. Now I am using a query on view to get a single batched data. when I am using direct query it was taking 0 sec but when I am using Through view "select *  from myView where batched=2" then its taking 30 mnt.

View 3 Replies View Related

How To View Data ?

Jun 20, 2006

I have table:
ID Name Value
1 A V1
2 B V2
3 A V3
4 E V4
5 A V5
6 G V6
7 B V7
8 E V8

Now i want to display :

Name : A
1 V1
3 V3
5 V5
Name : B
2 V2
7 V7
Name : E
4 V4
8 V8
Name : G
6 V6

Any one help me ?
Thank you very much.

View 2 Replies View Related

Get Data From A SQL View Using ADO.Net

Feb 19, 2008

When using ADO.Net to retrieve data from SQL Server into a SQLDataReader I use this code in a Data Access class:


public SqlDataReader GetView(string ViewName)
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = ViewName;
myCommand.CommandTimeout = 120;

// Mark the Command as a SPROC
[COLOR="Red"]myCommand.CommandType = CommandType.StoredProcedure[/COLOR];

// Execute the stored procedure and Return the datareader result
myConnection.Open();
return myCommand.ExecuteReader(CommandBehavior.CloseConnection)


This works fine when I am getting the data from a Stored Procedure.

But, on this occasion, I want to get the data from a View. How can I do this? There does not seem to be an option of CommandType.View

Thanks for any help.

View 3 Replies View Related

View Changes Data In A Column

Sep 17, 2001

Is there a way of changing the value of a column in a view? For example, I have a table with defect code and a description (other columns as well). In a view, I would like to see only the defect code and the description, but if the code is > 90, I would like to define what the description is.

TIA
Jennifer

View 2 Replies View Related

Data Partition View

Dec 31, 2003

Hi ,
I have question regard data partition view .

Please see below sample from BOL + sample of execution plane .

I would like to ask what is the way to avoid the optimizer scan tables out of the scope (I would expect that the only table for this query will be SUPPLY1)

Thanks,
Eyal




--This example uses tables named SUPPLY1, SUPPLY2, SUPPLY3, and SUPPLY4, which correspond to the supplier tables from four offices, located in different countries/regions.
USE tempdb
GO


--create the tables and insert the values
CREATE TABLE SUPPLY1 (
supplyID INT PRIMARY KEY CHECK (supplyID BETWEEN 1 and 150),
supplier CHAR(50)
)
CREATE TABLE SUPPLY2 (
supplyID INT PRIMARY KEY CHECK (supplyID BETWEEN 151 and 300),
supplier CHAR(50)
)
CREATE TABLE SUPPLY3 (
supplyID INT PRIMARY KEY CHECK (supplyID BETWEEN 301 and 450),
supplier CHAR(50)
)
CREATE TABLE SUPPLY4 (
supplyID INT PRIMARY KEY CHECK (supplyID BETWEEN 451 and 600),
supplier CHAR(50)
)
GO
--create the view that combines all supplier tables
CREATE VIEW all_supplier_view
AS
SELECT *
FROM SUPPLY1
UNION ALL
SELECT *
FROM SUPPLY2
UNION ALL
SELECT *
FROM SUPPLY3
UNION ALL
SELECT *
FROM SUPPLY4
GO

INSERT all_supplier_view VALUES ('1', 'CaliforniaCorp')
INSERT all_supplier_view VALUES ('5', 'BraziliaLtd')
INSERT all_supplier_view VALUES ('231', 'FarEast')
INSERT all_supplier_view VALUES ('280', 'NZ')
INSERT all_supplier_view VALUES ('321', 'EuroGroup')
INSERT all_supplier_view VALUES ('442', 'UKArchip')
INSERT all_supplier_view VALUES ('475', 'India')
INSERT all_supplier_view VALUES ('521', 'Afrique')

GO
/* */
SELECT * FROM all_supplier_view WHERE supplyID BETWEEN 1 and 150

View 7 Replies View Related

View Data In Query

Apr 9, 2008

Hi,
I have an accounting table with 5 year of data for an account, the table headers look as following

Acctno___Year___db_1,db_2,db,db_3,db4,….db_12,Cr_1,cr_2,cr_3…,cr-12

I want to with select statement to convert the data to query the header must be the following:-

Years1___Year2___year3___year4____year5
Db_1
Db_2
Db_3
.
.
.

Thanks for any help

View 3 Replies View Related

View Data From 2 Servers

Apr 6, 2006

Guys,

How do I create a view that will pull data from dbases on 2 different servers ?

I have 2 server names....

svr10mbr01
svr11mbr02

2 Databases...

PWBstaff on svr10mbr01
PWBdata on svr10mbr02

I need to create a view in PWBdata that will do something like....

Select * from PWBstaff.dbo.staff

Is this possible, if so what is the syntax.

Ta
Bob

"I dislilke 7am. If &am were a person, I would kick 7am in the biscuits." - Paul Ryan, dailyramblings.com

View 3 Replies View Related

Replicate A View With Data?

May 4, 2007

Hello,
I am trying to add a View to an existing publication and it the subscribers (all devices with SQL CE) don't get the View after replication. I have deleted and recreated the publication, and only the tables will appear on the device, not the view.

Also, I want the data from the view to be dynamic, filtered by using the Host_Name() function/value. Will this work for a View?

thanks
- will

View 3 Replies View Related

Updating Data In A View

Oct 2, 2007

Hello everyone,
Can someone help me with updating data into a view using triggers?
I am struggling hard to write a trigger or stored procedure to update the values on the base tables of the view.
Please help me out...
Thanks,
Godwin

View 5 Replies View Related

Getting Data In Particular Format In View

Jul 20, 2005

I want a report in excel from my SQL database from one table. I wantto create a view and then use DTS package to export it to excelformat.But how can i get the following format in a view?? They should begrouped by date.Date Column 1 column 2 column 329/10/2003 one $30.00 somedatetwo $45.00 somedata2three $67.00 somedata3Total ******** $142.0030/1/2003 blah blah blahblah blah blahand so on . How can i get such a format in a view.Thanks in advance. I can't use SHAPE command in view i guess.

View 1 Replies View Related

Modifying View Data

Mar 28, 2006

Hi,

I was asking how can I make updating and deleting for data through database views in Microsoft SQL Server 2005




Best Regards,

View 5 Replies View Related

Cant View Data In My Report

Oct 12, 2007



HI All,

I have a three table in my data base. I created a report using some of the fields in those three tables.
Table names are as follows.

Table1 - LoanApplication

Table2 - Member
Table3 - Rate

When I want to view sm fields from all three tables, it does not allow me to do that. I can not view data in the report.
I tried a query like this.




Code Block
SELECT LoanApplication.Uuid, LoanApplication.Status, LoanApplication.Amount, LoanApplication.Term,
LoanApplication.SubmittedOn, Member.LastName, Member.FirstName, Member.MiddleName, Member.CuStatus, Member.CUMemberId

FROM LoanApplication
INNER JOIN Member ON LoanApplication.MemberFK = Member.Id AND LoanApplication.Id = Member.LastLoanApplicationFK INNER JOIN Rate ON LoanApplication.RateFK = Rate.Id




There are realtionships of LoanApplication table with Rate and Member tables. But there is no relationship between Rate and Member.
When Rate table is included in the query, problem happens. When It is excluded , I can view the data in the report.


What is the reasone for this?

View 3 Replies View Related

SQL 2012 :: View And Obfuscating The Data

Sep 3, 2014

I need to create to create view on a table. Suppose if I have Firstname, Lastname & DOB in the physical table.

I need to mask the data from the original table. How can we do that?

Create view view_sample As
select ( null as Firstname, Hide as Lastname)

instead of the First name 'John', I just need to display null or something..

View 5 Replies View Related

Update Data In Grid View

Jul 19, 2013

I want to update a data in grid view

I have three columns in grid view

First two column are shift id and date these two column are taken from table 1

The third column is shift column this column are taken from table 2

Now I want to update a data where shift id and shift column are same

table 2 have these column
shift
shiftid

and table 1 has these column
shift id,
date

View 5 Replies View Related

Using A View To Omit Data From Another Table

Mar 21, 2007

Where it's select in red I want to be able to look in another table with a listing of email domains (@express.com,@express.net,@example.org), and when the are query that I don't view them. I don't know if I need some kind of varible or just lookup in another table. I have windows 2000, and same for SQL. I am trying to write it using SQL Query Analyzer.

Thank You,

Ernie


SELECT FirstName, LastName, Street, city, State, zip, Country, Providence, TypeOfAccount, RemoteComputerName, Timestamp1, PresentEmail, NewEmail,
Password, Age, Account_Active
FROM dbo.newusers
WHERE (FirstName <> ' NULL') AND (LastName <> ' NULL') AND (PresentEmail <> ' LOOKUP in another table') AND (NewEmail <> ' NULL') AND (Password <> ' NULL') AND
(Age <> ' NULL') AND (Account_Active <> 'yes') AND (Account_Active <> 'reject') AND (Account_Active <> 'spammer')

View 7 Replies View Related

Create A Column In A View Without Data

Feb 28, 2008

Hey everyone,

I have a view that shows the email address and first name of a Membership table. I need to add a column to this view that doesn't have a corresponding column in the original table that has some default value.

i.e. the view currently shows:

John john@something.com

I need it to say:

John john@something.com EmailBlast

The third column will always have that value.

Anyone have a suggestion?

Thanks in advance!

--J

View 2 Replies View Related

Data Type Change In SQL View

Jul 20, 2005

I've created a SQL View in SQL 2000 using a table that has columnsdefined as Numeric data type. In the view, I am grouping and summing.When I link the view via ODBC to Access, all of the data types arechanged to text. If I link the original table which the views arecreated from to Access, the data types are correct. So this problemobviously happens when I change the view to Group. Is there a wayaround this? I want the data types to be correct in Access when Ilink to the views.thanks,jim

View 1 Replies View Related

Conditionally Extraction Of Data From A View

Mar 19, 2007

Hi all,
I am really new to SSIS, so may be this is a really simple question, but I couldnt find an answer yet.
I need to build a package that
1) counts the rows from a view
2) if rowcount >0 extracts the data into a file

I tryed to do this using a Row Count Transformation in the data flow, but after putting the count in a variable I am not able to perform the "conditional" phase two.
I mean that I want to check the value of the variable, but cannot figure out how to conditionally execute the flat file extraction.

Using Row Count, I have to build 2 data flow tasks.
Is there a way to do this in a single data flow?
May be using an Execute SQL Task instead of row count?

Any suggestions will ge greately appreciated
IgorB

View 6 Replies View Related

View That Would Output Data From Two Views

Aug 8, 2007

OK,

I have two data tables where depending on the time line item it is, it needs a different join.

So, it's like this:

Table Credit Card
Table Memo

If Credit Card is VISA, join on column A
If Credit Card is MA, join on column B

So, I created two views. One view has all the info joined on column A. The other view has all the info joined on column B.

How do I create a third view that will output all the data from View A and View B without making it into a cartesian product?

I can't change the table structure due to legacy application/data issues.

Thanks!

View 3 Replies View Related

SELECT Data: Stored Procedures Or View?

May 10, 2007

Hi, I'm developing a fresh SQL DB which is result of a deep analysis of an old Access DB. THe thing is, this old one had very complex consultations to the Access tables, and some consultations were using another consultations as way to select some specific data. THe ideia in SQL is to avoid that too, however, there are some data that may serve exactly the same to some bigger stored procedures. This way, I have three options I guess: 1. Create every stored procedure making select queries directly to the table and it's done!2. Create auxiliary stored procedures which will select the redundant data, and when it is needed, another stored procedures call this one and use its returned data. (is this possible anyway?).3. I create a view to this redundant data, and the greater depth stored procedures access this data of the view when needed. I've heard, however, that a select to a view is slower than directly to the table, once the view adds an extra query to the process.. What is your guess on this issue of mine?I'm almost sure that option 1 is the best, however, I'd love to hear from you guys your opinion on this. The greater issue above this all is just one - performance. Thanks a lot! 

View 3 Replies View Related

How To View Binary Data In MSSQL 2005

Sep 5, 2007

Hi all,

I have a problem reading binary data in MSSQL using the Server Mgmt Studio. All it shows in the column is "<Binary data>". Is there a way to view this data at least the SIZE?

Thanks.

View 2 Replies View Related

Error Creating And Inserting Data Into VIEW

Feb 27, 2008

I have written following SQL query, this creates temporary table, inserts rows into it. I need to create VIEW "vw_NumberOfAttachments" in the database. I initially created table using "CREATE TABLE" but then i got error as VIEW can not be filled by temporary table. Hence I am using DECLARE TABLE
--------------------------------
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE sp_GetViewNumberOfAttachments
-- Add the parameters for the stored procedure here

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @emailMessageID bigint
DECLARE @metaDataStorageID bigint
DECLARE @numberOfAttachments int

DECLARE @AttachmentDetails TABLE
(
emailMessageID bigint,
metaDataStorageID bigint,
numberOfAttachments int
)

DECLARE ATTACHMENT_CURSOR CURSOR
FOR
SELECT emailMessageID, metaDataStorageID
FROM ppaEmailMessage
WHERE hasAttachments='true'

OPEN ATTACHMENT_CURSOR
FETCH NEXT FROM ATTACHMENT_CURSOR INTO @emailMessageID, @metaDataStorageID

WHILE @@FETCH_STATUS = 0
BEGIN
-- here the table name need to get dynamically the name of the attachment table
-- for a moment it is written as ppaMsOfficeDoc, but that should change dynamically
set @numberOfAttachments = (SELECT count(*) FROM ppaMsOfficeDoc WHERE metaDataStorageID = @metaDataStorageID)

INSERT INTO @AttachmentDetails(emailMessageID, metaDataStorageID, numberOfAttachments)
VALUES (@emailMessageID, @metaDataStorageID, @numberOfAttachments)

FETCH NEXT FROM ATTACHMENT_CURSOR INTO @emailMessageID, @metaDataStorageID
END

CLOSE ATTACHMENT_CURSOR
DEALLOCATE ATTACHMENT_CURSOR

IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME = 'vw_NumberOfAttachments')
DROP VIEW vw_NumberOfAttachments
GO
CREATE VIEW vw_NumberOfAttachments
AS
SELECT @AttachmentDetails.emailMessageID, @AttachmentDetails.metaDataStorageID, @AttachmentDetails.numberOfAttachments
FROM @AttachmentDetails
GO
END
GO

----------------------

I am getting following errors:
-----------
Msg 102, Level 15, State 1, Procedure sp_GetViewNumberOfAttachments, Line 57
Incorrect syntax near 'vw_NumberOfAttachments'.
Msg 137, Level 15, State 2, Procedure vw_NumberOfAttachments, Line 3
Must declare the scalar variable "@AttachmentDetails".
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'END'.
-----------
Can anyone please suggest whats wrong in there? Many thanks

View 1 Replies View Related

Create View With Data From Multiple Servers

Jul 23, 2005

Hi everyone,I have 5 servers, all with identical databases just different data. Ihave a rather lengthy SQL statement (in a View) to hit one database andpull-in certain data, but I'd like to somehow run this same SQLstatement within the view but hit all 5 servers so we don't have 5different versions of this data to mess with.I'm not opposed to creating an update query in a stored procedure tohit all 5 databases and update a table or even do this within a DTS,but I'd prefer to keep it as simple as possible and as dynamic so theusers can simply run the view and get live data anytime based on all 5tables.Is this possible ???Thanks,rlangly

View 2 Replies View Related

Indexes Being Improperly Used When Selecting Data Through A View

Nov 23, 2005

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

View 3 Replies View Related

Create View In SQL Server With Data Types

Aug 14, 2006

I need to create a view of a sql table, but change the data types. I knowthe syntax below is not correct, and can't figure out if it is wrong or ifyou just can't do this. I have only created views before with the same datatype.CREATE VIEW F0005New(DRKY nchar(3), DRDL01 nchar(30))INSERT (SELECT rtrim(F0005.DRKY), F0005.DRDL01FROM F0005 AS F0005WHERE DRSY = '41' AND DRRT = 'S1')Thanks!!

View 4 Replies View Related

Strange Behaviour Of Data Source View

May 29, 2008



I have a fact table which is a custim query in the data source view, I process and work with the data, after somewhile I make some changes in the data source view query but all my changes does not reflect in the cube after processing the same old data returned.

please help ASAP, I want to fix this issue

View 12 Replies View Related

Missing Data Set When Trying To View For A Finished Report

Mar 6, 2008



Hi All,
I have a solution which is synchronised with visualsourcesafe. Now there are some reports present in the solution, I am able to view the preview of the reports but when I am going to view the dataset definition It is not able to retain its defintion and its becoming blank but this happens to only datasets which were developed from cube and its able to retain dataset which are developed from Database.

Any help would be of great use.

Thanks in advance
Regards

View 1 Replies View Related

Can You Use A Stored Procedure In A Data Source View?

Aug 2, 2007

Is it possible to use a stored procedure in a Data Source View? When I use the wizard to create the Datasource View, all it lets me choose is tables and views in the database. Am I missing something, or trying to do something that is impossible?

View 8 Replies View Related

Report Models Data Source View

Apr 30, 2007

How does the report model know what data source view to use? I could not find it defined anywhere in the .smdl file.



My problem is this. I have a Report Model project with two data sources, two data source views and multiple report models. When I try and bind a data source to an entity in the report model I do not get to choose which data source view to use to choose what table/view I want to bind the entity too and only the tables in one of my DSV's shows up. When I first created it, it worked fine. It automatically selected the correct view and table and was successfully created but now when I open the project, that correlation is lost.



Any suggestions or help is appreciated, thanks.

View 1 Replies View Related







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