Making A Wide Table -- SQL Query

Sep 24, 2004

Hi Guys,
I have a requirement as follows:->

I have a table like below

EMPLOYEEID------- OWNS
********** ****
1-----------------car
1-----------------house
1-----------------dog
2-----------------house
3-----------------car
3-----------------bus
3-----------------shop
3-----------------hotel
3-----------------theater
3-----------------casino

Requirement:
I wanted to create another table based on the column values. For eg: I have to take the employee id and check for what value he has under owns column in the table. I take only 3 values and then these values should go to the newly created columns (owns1, owns2,owns3).
if there is no value for any of these columns it should have null values loaded in them.
The result of the modification should look like this:->

EMPLOYEEID-------OWNS1------OWNS2------OWNS3
*********** ***** ***** *
1-----------------car--------house------dog
2-----------------house------Null-------Null
3-----------------car--------Bus--------shop

Note: eventhough employeeid 3 owns more than 3 things we only take 3 of what he owns and populate to above coloumns.
In addition to it, the column OWNS will have more than 500 different values in them.

Its kind of urgent and if anyone knows how to , Can you please help me on this.
Thanks a lot.
-- Ragulan
;)

View 3 Replies


ADVERTISEMENT

Making A Table From A Query

Feb 10, 2004

I have a Query named qryQuery1 from which I would like to make a Table named tblTable1. I need to do this within a VBA Microsoft Access module.

Can anyone help me with the proper code?

Thank you for any help.

Jim

View 14 Replies View Related

Making Date Dynamic In Pivot Table Query

Apr 16, 2008

I have a pivot table query I am running and wanted to find out if there was a way to pull in the dates like getdate() - 12 months, getdate() - 11 months, etc. instead of hard coding the dates.

Here is my query

SELECT Client, [4/1/2007 12:00:00 AM] AS Month1, [5/1/2007 12:00:00 AM] AS Month2, [6/1/2007 12:00:00 AM] AS Month3, [7/1/2007 12:00:00 AM] AS Month4,
[8/1/2007 12:00:00 AM] AS Month5, [9/1/2007 12:00:00 AM] AS Month6, [10/1/2007 12:00:00 AM] AS Month7, [11/1/2007 12:00:00 AM] AS Month8,
[12/1/2007 12:00:00 AM] AS Month9, [1/1/2008 12:00:00 AM] AS Month10, [2/1/2008 12:00:00 AM] AS Month11, [3/1/2008 12:00:00 AM] AS Month12,
[4/1/2008 12:00:00 AM] AS Month13, Engineer
FROM (SELECT Client, DollarsBilled, SlipDates, Engineer
FROM dbo.MonthlyClientBillables) p PIVOT (SUM(DollarsBilled) FOR SlipDates IN ([4/1/2007 12:00:00 AM], [5/1/2007 12:00:00 AM],
[6/1/2007 12:00:00 AM], [7/1/2007 12:00:00 AM], [8/1/2007 12:00:00 AM], [9/1/2007 12:00:00 AM], [10/1/2007 12:00:00 AM], [11/1/2007 12:00:00 AM],
[12/1/2007 12:00:00 AM], [1/1/2008 12:00:00 AM], [2/1/2008 12:00:00 AM], [3/1/2008 12:00:00 AM], [4/1/2008 12:00:00 AM])) AS pvt

View 31 Replies View Related

Split Wide, Denormalized Table Into Normalized Structure

Aug 27, 2002

Thanks for reading.

This is pretty long, hopefully it isn't rambling.

I'm building a system that imports data from several source, Excel files, text files, Access databases, etc. using DTS. The entire process revolved around MS SQL Server, by the way.

I figured I would create denormalized tables that mirror the Excel and flat files, for example, in structure, import data to those, clean up and remove duplicates there, then break those out into my normalized table structure later.

Now I've finished the importing part (though this is going to happen once a week) and I'm onto breaking up the denormalized tables.

I'm hesitating because I'm not sure I've made the best decisions in terms of process, etc.

I've decided to use cursors to loop over the denormalized tables and use batch insert statements to push data out to the appropriate tables.

Any comments? Suggestions? All is welcome.

I'm specifically interested in hearing back on the way I've set up the intermediate, denormalized tables and how I'm breaking them up using cursors (step 2 of the process below). Still, all comments are welcome. As are suggestions for further reading.

Thanks again...

simplified example
(my denormalized tables are 20 - 30 colums wide)

denormalized table:
===================
name, address, city, state, cellphone, homephone


normalized tables:
==================

tblPerson [PK_person, name, age, height, weight]
tblAddress [PK_address, FK_person, street, city, state, zip, addressType]
tblContact [PK_contact, FK_person, data, contactType]


I'm breaking up the denormalized tables like this (*UNTESTED*):
=================================================

DECLARE @vars.... (one for each column in my normalized table structure, matching size and type)

DECLARE myCursor CURSOR
FAST_FORWARD FOR
SELECT name, address, city, state, cellphone, homephone
FROM _DNT_myWideTable
INTO

WHILE @@Fetch_Status = 0
BEGIN
-- grab the next row from the wide table
FETCH NEXT FROM myCursor
INTO @name, @address, @city, @state, @cellphone, @homephone


-- create the person first and get the ID with @@IDENTITY
INSERT INTO tblPerson (name) VALUES (@name)

SET @personID = @@IDENTITY


-- use that ID to coordinate inserts across other tables
INSERT INTO tblAddress (FK_person, address, city, state, addressType)
VALUES(@person, @address, @city, @state, 'HOME')

INSERT INTO tblContact (FK_person, data, contactType)
VALUES(@person, @cellphone, 'CELLPHONE')

INSERT INTO tblContact (FK_person, data, contactType)
VALUES(@person, @homephone, 'HOMEPHONE')

END

View 1 Replies View Related

Howto Do Totaling In Column Wide In Matrix Table

Jun 14, 2005

Hi

View 10 Replies View Related

Removing Blank Space Caused By Wide Table

Apr 5, 2007

Hi all,



Report:

-For instance 2 small tables (eg. width 10cm = 3 inch?)

-And one wide table (eg. width 30cm = 10 inch?)

All separated by "insert pagebreak after table".



Problem:

When rendered, the pages with the small tables on have a lot of white blank space at the right of the table. This is probably caused by the big table on page 3.

This report is distributed by email in Excell format. So on sheet 1 and 2 there are a lot of white cells on the right of the tables. When trying to print, they just want to use the "landscape" option and the "fit to page" option. Because of the empty white cells, the fit to page option reduces the first 2 tables to a very small table which covers only 50 % of the page width. The other 50 % is reserved for the empty cells.



Off course, I know that deleting the empty cells offers a solutions, but it would be a lot more handier if there were no empty cells in the first place.



Anybody with a solution?

View 2 Replies View Related

Integration Services :: How To Insert Rows In A Wide Table With Over 13K Columns

Aug 21, 2015

I have a flat file with 13K columns which I need to load in a wide table.

The flat file does not even have column names and no datatypes defined.

How to load data in the wide table?

Also if i choose to load the data in 13 different work tables.

How do I define datatypes in the flatfile connection manager in SSIS for 13000 columns ?

View 5 Replies View Related

Transact SQL :: How To Bulk Insert Rows From Text File Into A Wide Table Which Has 1400 Columns

Feb 3, 2010

we can easily load a file into db tables. However, my main concern here is the number of columns in the file. A text file TEXT_1400.txt has 1400 columns. I am unable to load data to my db table using BCP or BULK INSERT commands, as maximum of 1024 columns are allowed per table in SQL Server 2008. 

We can still go ahead and create ‘Wide Table’ (a special table that holds up to 30,000 columns.  The maximum size of a wide table row is 8,019 bytes.). But when operating on wide table, BCP/BULK INSERT commands still fail. After few hours of scratching my head over BCP and BULK INSERT, I observed that while inserting BCP/BULK INSERT commands are unable to identify SPARSE columns and skip these columns, which disturbs column mapping and results in data conversion and trancation errors.
 
Is there any proper way to load this kind of files into the db table? 

View 6 Replies View Related

Making A SQL Update Query Run Once

Aug 22, 2005

I have a datagrid in my file along with an Update Query.

My Update Query basically adds the numerical values in two columns
together when the page is loaded. This means whenever the page is
Refreshed the Update query is fired.

This is my Update Query (which is in an Stored Procedure):

UPDATE Rental
SET TotalFee = ExtraFee + TotalFee
WHERE DaysOverdue >= 0

I have declared my query in the 'Page_Load' part of the coding, because
I want the query to run automatically. Not manually by a button.

My main question is that how can I get the query to run only once a day, no matter how many times the page is loaded.

View 7 Replies View Related

Help Me Making FOR XML QUERY Plezz!!

Sep 20, 2007

OK Here goes my BIG question


I've following database structure (just junk values)

[ChannelID]---[ChannelName]---[ChannelCatID]---[RSSFeedURL]

1---YouTube---1---ret---
2---GoogleVideo---1---ert---
3---MSNVideo---1---rtertert---
4---ABC---2---retert---
5---YahooVideo---1---erter---
6---CBS---2---rtr---
7---NBC---2---trtrt---
8---ESPN---2---rt---
9---FOX---2---rtrtttr---
10---AOL---1---rt---

I wanna generate following XML structure out of it

<DOC>
-<Item Type="xyz">
--<Channel id="a">
---<Name>aaaaa<Name/>
---<URL>aaaaa<URL/>
--</Channel>

--<Channel id="b">
---<Name>bbbb<Name/>
---<URL>bbbb<URL/>
--</Channel>
---
---
-</Item>

-<Item Type="lmn">
--<Channel id="x">
---<Name>xxxx<Name/>
---<URL>xxxx<URL/>
--</Channel>

--<Channel id="y">
---<Name>yyyy<Name/>
---<URL>yyyy<URL/>
--</Channel>
---
---
-</Item>
------
------
------
</DOC>

I've written this Select For XML query

SELECT ChannelCatID as '@type',
ChannelID as 'Channel/@id',
ChannelName as 'Channel/Name',
RSSFeedURL as 'Channel/URL'
FROM ChannelMaster
FOR XML PATH('Item'), ROOT('DOC')


It gives me this result
<DOC>
-<Item Type="xyz">
--<Channel id="a">
---<Name>aaaaa<Name/>
---<URL>aaaaa<URL/>
--</Channel>
-</Item>
-<Item Type="xyz">
--<Channel id="b">
---<Name>bbbb<Name/>
---<URL>bbbb<URL/>
--</Channel>
-</Item>
-<Item Type="xyz">
---
-</Item>
-<Item Type="xyz">
---
-</Item>
------
------
------
</DOC>

I want it this way :

all channels of Type xyz should come under singe <Item Type="xyz"> tag instead of seperate tags

what changes should i make, plezz help meout wit dis ??

.(][)[](][).

View 1 Replies View Related

Making Two Sums In One Query

Jun 10, 2006

Hi

Im new in this forum so don't if this is the right place to post these kind of questions..

Im using vb2005 and have made a program that deals with customers and payments.

I have a table called acount. Roughly it contains these columns

Number, amount, type..

type can be a payment or a charge

I would like to have a query that gives me this result:

Number, sum(payments), sum(charges) (grouped by number)

I think it is some type of merging these to querys

select number, sum(amount) where type = 0 group by number

and

select number, sum(amount) where type <> 0 group by number

Im using it to calculate a customers acount to see if they have paid to much or to little.

Any ideas?

View 6 Replies View Related

Slow Performance When Making A Query

Aug 1, 2005

I have a table with about 20,000 records.  So, to minimise performance issues, i try to only retrieve the top 100 records.  The databaset retrieved can be paged and sorted.  Below is my code, but it's taking quite a while even to only load the 100 records.  Any suggestions?Private Sub BindGrid()        Dim connectionString As String = "MyConnectionString"        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
         Dim queryString As String = "SELECT TOP 100 [Person].* FROM [Person] ORDER BY " & viewstate("sortField").ToString() & " " & viewstate("sortDirection").ToString()
        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand        dbCommand.CommandText = queryString        dbCommand.Connection = dbConnection
        Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter        dataAdapter.SelectCommand = dbCommand        Dim dataSet As System.Data.DataSet = New System.Data.DataSet        dataAdapter.Fill(dataSet)
        Try           DataGrid1.DataSource = dataSet           DataGrid1.Databind()        Catch e As Exception           DataGrid1.CurrentPageIndex = 0        End TryEnd Sub

View 1 Replies View Related

Making A Statistics Table....

Jan 31, 2007

hi. i'm trying to make a report in asp that sums up a whole bunch of statistics. the report is quite lengthy and takes about 2 minutes to load. i thought i would solve that problem by making a table to dump the statistics into instead of calculating the statistics every time the report is viewed. this way, the page would just read the table with the statistics already put in it. these statistics would be updated every day or two so i don't need anything up to the minute.however, i have run into a small problem which is actually updating the information in the table. my new table is called OfficeReport and it looks like this:UserID Stat1 Stat2 Stat3 ...... Stat3223 0 0 0 056 0 0 0 072 0 0 0 0this is a query for one of the statistics i am currently using:SELECT DefendantCase.UserID, COUNT(DefendantCase.UserID) AS CountOfUserID FROM DefendantCase LEFT JOIN UserDescription ON DefendantCase.UserID=UserDescription.UserID WHERE UserDescription.Status=1 AND UserDescription.UserType=1GROUP BY DefendantCase.UserIDif i run this query, this is what i get:UserID CountOfUserID54 2160 1052 294 427 22how can i modify this query so its output updates the same UserID column in the OfficeReport table? Thanks!

View 3 Replies View Related

Making A Copy Of A Table

Apr 3, 2006

I need to make a backup of a table so that if I mess it up I can put the data back to where I started...

I am going to insert some new rows and update values in some existing rows. So before I do this and find out I messed it up...how do I make a copy of Table A as Table B?

I would actually like to make a copy to table B, then run my changes into B, make sure all is correct, and then transfer the revised data from B over to table A replacing its data. What approach would be best here to accomplish this?

Thanks

View 2 Replies View Related

Using Local Variable Making The Query Slow

May 28, 2008


Hi,

I am using a local variable to capture datetime and then select records from another table by making use of the above local variable result. But the query is running too slow when I use the local variable

declare @a smalldatetime
select @a=last_run_time from job_status
where job_des='sample'


SELECT * FROM History
WHERE CHANGE_DATE> @a

Instead of the above select statement if I use the below statement it is returning results quickly. Can someone help me in tuning the above query.
SELECT * FROM History
WHERE CHANGE_DATE> '5/23/2008 6:22:00.000 AM '

History table has columns ( case number, change_date, change_desc). I have two indexes defined on the above table one is on case_number and the other on change_date.I tried using force index but still the query is running slow.

will there be any difference if use dynamic sql ?

View 7 Replies View Related

Making A Query Have Flexible Index Utilization

Apr 29, 2008

I have one query that looks like this.

DECLARE @propname

SET @propname = NULL -- can be Null or have wild card values

SELECT col1, col2, col3, propertyname FROM testtable where col1 = 1 and col2 = 2 and col3 = 3 and (@propname IS NULL OR propertyname LIKE @propname)

col1, col2, col3 are part of a clustered index

propertyname is a nonclustered index

This is the predicament. If the "@propname is NULL" is first in the OR statement then the query will use the clustered index for finding the record. If I put "@propname is NULL" last then it uses the propertyname index no matter what. So I either get full index scans if NULL is ever used on property names or I get consistent two second long searches on the clustered index. Any way to have the best of both worlds? Or do I have to divide up my query into more stored procedures?

THANKS

View 11 Replies View Related

Making Part Of A Table Name Into A Variable

Aug 23, 2007

I have a huge question, it's for my job im doing now. I have a table with the name TWO.dbo.SVC06105. I want to be able to take the word "TWO" and put that into a variable. I know this doesn't look correct, but I want to be able to do something like this:

DECLARE @GPNAME CHAR(100)
SET @GPNAME = 'TWO'

SELECT * FROM @GPNAME.dbo.SVC06105

I know the SELECT statement isn't correct, but I hope that you guys understand what i'm trying to do through this example. BTW, I am new to this team so nice to meet you all. L8er

View 4 Replies View Related

Problem With Making A Sqldatasource For Inserting Using The Query Builder

Aug 19, 2007

I want to make a sqldatasource to insert data ito a table with values from textfields page. I want to use the sqldatasource programically (not bind it to a formcontrol).
I drag a sqldatasource from the toolbox to the design surface and start configuring the datasource. I spesify a custom sql statement, select the "Insert" tab and insert the table I want to store into the builder. Then I select the fields and the values (parameters from tue textfields. I test it with the "Execute query" button and the results is stored in the table. (everything seems ok) I press the "OK" button but both the "Next" and "Finish" buttons are dissabled, o I can not store the query.
What is going wrong. Can someone please help me ?
Tom Knardahl

View 2 Replies View Related

SQL 2012 :: Count Rows When Making New Table

Jan 8, 2015

How can I count the rows when I make new table. Here is my code:

SELECT EMPLOYEE_ID, LAST_NAME, SALARY, JOB_ID, COMMISSION_PCT, DEPARTMENT_ID, COUNT(TO_CHAR(HIRE_DATE, 'DAY')) AS NUM_EMPLOYEES
FROM EMPLOYEES
WHERE TO_CHAR(HIRE_DATE, 'Day') = 'Monday'
GROUP BY EMPLOYEE_ID, LAST_NAME, SALARY, JOB_ID, COMMISSION_PCT, DEPARTMENT_ID;

Here is the table: [URL] ....

I have 10 rows, so I would like under NUM_EMPLOYEES to be displayed 10 on each row.

View 5 Replies View Related

Making The Value Of One Coloumn The Same For A Large Set Of Data In A Table?

Nov 19, 2007

Hello, Im a very new to SQL server etc, so please bear with me.

I am currently trying to find a quick way of making a large number of database entries within a particular table all have the same value in one particular column.

I have created a query in MS SQL Server Management Studio, which outputs all the entries in a particular table that I want to change. Currently they all have different values in a certain column in this table, and I want them all to have the same value in that column.

How do I do this within Server Management Studio?

Thank you.

View 3 Replies View Related

SQL Server 2012 :: Making Query For Presenting Data In Different Format?

Jun 18, 2015

I have below table:

IF OBJECT_ID('tempdb..#complaints') IS NOt NULL
DROP TABLe #complaints

--===== Create the test table with

create table #cs([Year] float,
[Week] float,
[Month] float,
[C#] float,
[Dept] nvarchar(255)
,[Issue] nvarchar(255), [Type] nvarchar(255), [Dept age] nvarchar(255))

--===== All Inserts into the IDENTITY column

INSERT INTO #cs
([Year], [ Week], [ Month], [C#],[Dept],[Issue], [Type], [Dept age])
SELECT 2015, 14, 4, 188, D1,I1,T1, 5 UNION ALL
SELECT 2015, 14, 4, 452,d1, I1, T2, 5 UNION ALL
SELECT 2015, 14, 4, 63, d1, I1, T1, 6 UNION ALL
SELECT 2015, 14, 4, 9, d1,I2, T1, 7 UNION ALL
SELECT 2014, 14, 4, 187, D1,I1,T1, 5 UNION ALL
SELECT 2014, 14, 4, 451,d1, I1, T2, 5 UNION ALL
SELECT 2014, 14, 4, 62, d1, I1, T1, 6 UNION ALL
SELECT 2014, 14, 4, 10, d1,I2, T1, 7 UNION ALL)

and i want to have a table in below format: (query for it)

Week, Month, C1#,c2# Dept,Issue, Type, Dept age
14, 4 188 187 d1 i1 t1 5
14, 4 452 451 d1 i1 t2 5

I.E. I WANT two columns C1# and C2#, where C1# contains data from 2015 and C2# contains data from previous year (2014). If 2015 data is not present, then C1# will contain data of 2014 and C2# will contain data of 2013.

View 9 Replies View Related

After Sorting Textbox Is Getting Collapsed Making Table Invisible

Apr 15, 2008


Hi.



I found unpleasant issue within RS:

1. Imagine RS report with Table(with interactive sorting) whose visibility is toggled by Textbox:


2. After sorting the Table the Textbox is getting collapsed making the Table invisible. But the Table should remain visible.

Is this MS bug? Are there workarounds?

If my question is not understandable I can send simple *.rdl report with sample.

Thank you in advance for help.

View 7 Replies View Related

Making A (sort Of) Dynamic Pivot Table. I'm Stumped

May 11, 2008

Hello,

I've seem some good posts similair to this, but I haven't been able to find my exact issue.

I have the following table:







ID
Name
Location
Start
End

1
Joe
NY
2000
2001

1
Joe
CA
2002
2004

1
Joe
MA
2005
2008

2
Sue
NJ
2003
2004

2
Sue
FL
2004
2008

3
Bob
CA
1999
2000

3
Bob
WA
2001
2004

3
Bob
OR
2005
2006

3
Bob
MI
2007
2008


As you can see, the Location, Start and End dates can vary for each person and I don't know how many rows a single person might have.


The result I want, is a "pivot like" table.







ID
Name
Location1
Start1
End1
Location2
Start2
End2
Location3
Start3
End3
Location4
Start4
End4

1
Joe
NY
2000
2001
CA
2002
2004
MA
2005
2008




2
Sue
NJ
2003
2004
FL
2004
2008







3
Bob
CA
1999
2000
WA
2001
2004
OR
2005
2006
MI
2007
2008


I assume I can first do a count of the maximum rows for an individual and that is greatest number of columns I would need. But doing that and trying to figure out the rest has really stumped me.


Any thoughts, ideas and suggestions would be greatly appreciated.

Thank you.

-Gumbatman

View 11 Replies View Related

Making Changes To A Table With Lots Of Data. Timeout Error?!

Oct 11, 2006

Hello,

I have a table that is fairly large, and I need to make a change to one of the columns in the table. Namely I need to change the datatype and rename that column. When I try to save the updated table, I keep getting a timeout error that says.

'eligibility (dbo)' table
- Unable to create index 'PK_eligibility'.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Any ideas on how to make the table change more efficient or change the timeout period. I need to keep the existing data in the table. I am using sql server managment studio(2005) connected to a sql server 2000 database.

Thanks!

View 7 Replies View Related

How Wide Is Too Wide???

May 22, 2000

Is a table 45 columns wide too wide? Most of the data is very small( check boxes, one word fields etc.) I have one giant form that needs to be filled out and uploaded to the database. I don't want to fragment the table too much because it will be a pain to update it. This table will have to be searched, that's why I am concerned with the width. I am hoping that an index would help out and would provide enough performance that I can keep a wide table.

Thanks,
Nathan

View 4 Replies View Related

Wide Db Search

Jan 4, 2008

ok, i have been charged with the task of searching a server that houses 50-60 client databases. all databases are identical, created from a prototype. i have discovered an issue whereby one of the clients db is missing a required sproc. they now want me to check all db's to see if anyone else is missing the sproc or not.  i have a UN and PASS to login to the server that houses all db's. is there a method for me to query all db's at once and check for the sproc? or will i have to go through them all manually (which could become quite time consuming as there are so many db's, and quite a large number of sprocs in each. the sprocs seem to be listed in a semi-random order in each db as well)
thanks all

View 1 Replies View Related

Server Wide UDF

Jul 10, 2007

Is there any way to create Server wide UDFs? We have alot functions that are spread across multiple databases and its time consuming going around databases looking for them. What would be nice is to create functions at the server level which can be accessed within any database, like the GETDate() function.

Thanks in advance.

View 2 Replies View Related

Wide Primary Keys

Jul 23, 2005

I'm working on a system that is very address-centric and detection ofduplicate addresses is very important. As a result we have brokenaddresses down into many parts (DDL below, but I've left out somereference tables for conciseness), these being state, locality, street,street number, and address. The breakdown is roughly consistent withAustralian addressing standards, we're working on finalising this.Because we carry the primary key down each of the levels, this hasresulted in our address table having a very wide primary key (around170 characters). We refer to addresses from a number of other tablesand although my instinct is to use this natural key in the other tablesI wonder if we should just put a unique index on the natural key,create a surrogate primary key and use it in the other table. Anythoughts?CREATE TABLE dbo.States (StateID varchar (3) NOT NULL ,StateName varchar (50) NOT NULL ,CONSTRAINT PK_AddressStates PRIMARY KEY NONCLUSTERED(StateID))CREATE TABLE dbo.Localities (Locality varchar (46) NOT NULL ,StateID varchar (3) NOT NULL ,Postcode char (4) NOT NULL ,CONSTRAINT PK_Localities PRIMARY KEY NONCLUSTERED(Locality,StateID,Postcode),CONSTRAINT FK_AddressLocalities_AddressStates FOREIGN KEY(StateID) REFERENCES dbo.States (StateID))CREATE TABLE dbo.Streets (StreetName varchar (35) NOT NULL ,StreetTypeID varchar (10) NOT NULL ,StreetDirectionID varchar (2) NOT NULL ,Locality varchar (46) NOT NULL ,StateID varchar (3) NOT NULL ,Postcode char (4) NOT NULL ,CONSTRAINT PK_Streets PRIMARY KEY CLUSTERED(StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode),CONSTRAINT FK_Streets_Localities FOREIGN KEY(Postcode,Locality,StateID) REFERENCES dbo.Localities (Postcode,Locality,StateID))CREATE TABLE dbo.StreetNumbers (StreetName varchar (35) NOT NULL ,StreetTypeID varchar (10) NOT NULL ,StreetDirectionID varchar (2) NOT NULL ,Locality varchar (46) NOT NULL ,StateID varchar (3) NOT NULL ,Postcode char (4) NOT NULL ,StreetNumber varchar (15) NOT NULL ,BuildingName varchar (100) NOT NULL ,CONSTRAINT PK_StreetNumbers PRIMARY KEY CLUSTERED(StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode,StreetNumber),CONSTRAINT FK_StreetNumbers_Streets FOREIGN KEY(StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode) REFERENCES dbo.Streets (StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode))CREATE TABLE dbo.Addresses (StreetName varchar (35) NOT NULL ,StreetTypeID varchar (10) NOT NULL ,StreetDirectionID varchar (2) NOT NULL ,Locality varchar (46) NOT NULL ,StateID varchar (3) NOT NULL ,Postcode char (4) NOT NULL ,StreetNumber varchar (15) NOT NULL ,AddressTypeID varchar (6) NOT NULL ,AddressName varchar (20) NOT NULL ,CONSTRAINT PK_StreetNumberPrefixes PRIMARY KEY CLUSTERED(StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode,StreetNumber,AddressTypeID,AddressName),CONSTRAINT FK_Addresses_StreetNumbers FOREIGN KEY(StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode,StreetNumber) REFERENCES dbo.StreetNumbers (StreetName,StreetTypeID,StreetDirectionID,Locality,StateID,Postcode,StreetNumber))

View 3 Replies View Related

Types Of Joins In Version Wide

Nov 1, 2007

Dear All,
what are different types of joins avialable with sql server6.0, 7.0, 2000 and 2005 and now 2008...

the reason behind the question is :

i've used the swiss Sql tool to boost the performance of my join queries. and the tool has given some best options. those are working fine with database but failing at application level.

i found the reason is because of Loop join, Hash Join, Merge join.


your valubel suggsions are needed.


thank you veru much

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 7 Replies View Related

Custom Object Wide Roles

Jan 23, 2006

Can we create custom object wide roles? In the same manner that db_datareader in effect grants SELECT on all tables, can we create roles that affect all objects without having to explicitly grant the permission on every object?

View 1 Replies View Related

Changing All VARCHAR To NVARCHAR Database-wide?

Jan 15, 2005

Hi,
I have an ASP.NET application that uses VARCHAR extensively in the tables and, more importantly, stored procedures (a couple hundred of them).

This app needs to start accepting foreign language in some areas, so I was wondering if there was some way to go through the tables and, more importantly, the stored procedures and change all "VARCHAR" references to "NVARCHAR" ?

Are the stored procedures stored as a text file somewhere on the server? If so I could use some sort of "replace" software utility to go through and change all VARCHAR to NVARCHAR

thanks!

-Bret

View 2 Replies View Related

Upper/lowe Case Set In Server Wide

Nov 3, 2004

Hi,
Can we set the Uper/Lower case in server wide in SQL server 2000 as like case sensitive.
Thanks,
Ravi

View 6 Replies View Related

Analysis :: Split Wide Measure Group?

May 14, 2015

I have a wide fact table that I'm feeding to an SSAS cube. I was advised that splitting the measure group into two will improve performance when querying the cube.

I cannot find any documentation that supports this, in fact I get a blue curved line suggesting that I merge the measure groups since they have the same dimensionality and granularity.

I guess the best practice is what the blue line states, but without knowing the internals of SSAS I can undestand that a smaller measure group may be easier to handle, or create more specific aggregations for.

View 4 Replies View Related







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