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?
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!!
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.
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.
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 *"?
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
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?
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
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.
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.
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')
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'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
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
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!
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?
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 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
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
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
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!!
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.
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.
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?
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.
Is there a limit on the number of fields that can be displayed in a table object in a data source view in SSAS 05? One of the tables (the fact table) in my data source view is displaying only 50 fields. The table actually has many more than that. One of the fields that is not displaying is a foreign key that I need to link to a new dimension table. I have tried refreshing the view, but it doesn't bring in any additional fields.