TSQL - PARTITION BY / OVER Functions
Sep 5, 2007Hi,
Are the functions
PARTITION BY and OVER exist in SQL SERVER 2000?
Can I have an example please?
Thanks in advance,
Aldo.
Hi,
Are the functions
PARTITION BY and OVER exist in SQL SERVER 2000?
Can I have an example please?
Thanks in advance,
Aldo.
Hi,
I have a good collection of UDFs in my store,anybody interested to get those plz echo I want...
:angel:
ive created a function OrdersAmount that will accept two parameters: the start date and the end
date, and that will return the total order amount between those two dates. i am testing
the function by listing the rows from the table and the function result.
but i am getting some syntax errors
create function dbo.OrdersAmount(@startdate datetime, @enddate datetime)
returns int
as
begin
declare @return int
set @return = (select sum(od.UnitPrice * od.OrderQty * (1-od.unitpriceDiscount)) as totalorderamount from Orderdetails od
inner join orders o on od.salesorderid=o.salesorderid
where orderdate between @startdate and @enddate)
return @return
end
Msg 8117, Level 16, State 1, Procedure OrdersAmount, Line 6
Operand data type nvarchar is invalid for multiply operator.
would anybody know why?
I was playing around with the new SQL 2005 CLR functionality andremembered this discussion that I had with Erland Sommarskog concerningperformance of scalar UDFs some time ago (See "Calling sp_oa* infunction" in this newsgroup). In that discussion, Erland made thefollowing comment about UDFs in SQL 2005:[color=blue][color=green]>>The good news is that in SQL 2005, Microsoft has addressed several of[/color][/color]these issues, and the cost of a UDF is not as severe there. In fact fora complex expression, a UDF in written a CLR language may be fasterthanthe corresponding expression using built-in T-SQL functions.<<I thought the I would put this to the test using some of the same SQLas before, but adding a simple scalar CLR UDF into the mix. The testinvolved querying a simple table with about 300,000 rows. Thescenarios are as follows:(A) Use a simple CASE function to calculate a column(B) Use a simple CASE function to calculate a column and as a criterionin the WHERE clause(C) Use a scalar UDF to calculate a column(D) Use a scalar UDF to calculate a column and as a criterion in theWHERE clause(E) Use a scalar CLR UDF to calculate a column(F) Use a scalar CLR UDF to calculate a column and as a criterion inthe WHERE clauseA sample of the results is as follows (time in milliseconds):(295310 row(s) affected)A: 1563(150003 row(s) affected)B: 906(295310 row(s) affected)C: 2703(150003 row(s) affected)D: 2533(295310 row(s) affected)E: 2060(150003 row(s) affected)F: 2190The scalar CLR UDF function was significantly faster than the classicscalar UDF, even for this very simple function. Perhaps a more complexfunction would have shown even a greater difference. Based on this, Imust conclude that Erland was right. Of course, it's still faster tostick with basic built-in functions like CASE.In another test, I decided to run some queries to compare built-inaggregates vs. a couple of simple CLR aggregates as follows:(G) Calculate averages by group using the built-in AVG aggregate(H) Calculate averages by group using a CLR aggregate that similatesthe built-in AVG aggregate(I) Calculate a "trimmed" average by group (average excluding highestand lowest values) using built-in aggregates(J) Calculate a "trimmed" average by group using a CLR aggregatespecially designed for this purposeA sample of the results is as follows (time in milliseconds):(59 row(s) affected)G: 313(59 row(s) affected)H: 890(59 row(s) affected)I: 216(59 row(s) affected)J: 846It seems that the CLR aggregates came with a significant performancepenalty over the built-in aggregates. Perhaps they would pay off if Iwere attempting a very complex type of aggregation. However, at thispoint I'm going to shy away from using these unless I can't find a wayto do the calculation with standard SQL.In a way, I'm happy that basic SQL still seems to be the fastest way toget things done. With the addition of the new CLR functionality, Isuspect that MS may be giving us developers enough rope to comfortablyhang ourselves if we're not careful.Bill E.Hollywood, FL------------------------------------------------------------------------- table TestAssignment, about 300,000 rowsCREATE TABLE [dbo].[TestAssignment]([TestAssignmentID] [int] NOT NULL,[ProductID] [int] NULL,[PercentPassed] [int] NULL,CONSTRAINT [PK_TestAssignment] PRIMARY KEY CLUSTERED([TestAssignmentID] ASC)--Scalar UDF in SQLCREATE FUNCTION [dbo].[fnIsEven](@intValue int)RETURNS bitASBEGINDeclare @bitReturnValue bitIf @intValue % 2 = 0Set @bitReturnValue=1ElseSet @bitReturnValue=0RETURN @bitReturnValueEND--Scalar CLR UDF/*using System;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using Microsoft.SqlServer.Server;public partial class UserDefinedFunctions{[Microsoft.SqlServer.Server.SqlFunction(IsDetermini stic=true,IsPrecise=true)]public static SqlBoolean IsEven(SqlInt32 value){if(value % 2 == 0){return true;}else{return false;}}};*/--Test #1--Scenario A - Query with calculated column--SELECT TestAssignmentID,CASE WHEN TestAssignmentID % 2=0 THEN 1 ELSE 0 END ASCalcColumnFROM TestAssignment--Scenario B - Query with calculated column as criterion--SELECT TestAssignmentID,CASE WHEN TestAssignmentID % 2=0 THEN 1 ELSE 0 END ASCalcColumnFROM TestAssignmentWHERE CASE WHEN TestAssignmentID % 2=0 THEN 1 ELSE 0 END=1--Scenario C - Query using scalar UDF--SELECT TestAssignmentID,dbo.fnIsEven(TestAssignmentID) AS CalcColumnFROM TestAssignment--Scenario D - Query using scalar UDF as crierion--SELECT TestAssignmentID,dbo.fnIsEven(TestAssignmentID) AS CalcColumnFROM TestAssignmentWHERE dbo.fnIsEven(TestAssignmentID)=1--Scenario E - Query using CLR scalar UDF--SELECT TestAssignmentID,dbo.fnIsEven_CLR(TestAssignmentID) AS CalcColumnFROM TestAssignment--Scenario F - Query using CLR scalar UDF as crierion--SELECT TestAssignmentID,dbo.fnIsEven_CLR(TestAssignmentID) AS CalcColumnFROM TestAssignmentWHERE dbo.fnIsEven(TestAssignmentID)=1--CLR Aggregate functions/*using System;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using Microsoft.SqlServer.Server;[Serializable][Microsoft.SqlServer.Server.SqlUserDefinedAggregate (Format.Native)]public struct Avg{public void Init(){this.numValues = 0;this.totalValue = 0;}public void Accumulate(SqlDouble Value){if (!Value.IsNull){this.numValues++;this.totalValue += Value;}}public void Merge(Avg Group){if (Group.numValues > 0){this.numValues += Group.numValues;this.totalValue += Group.totalValue;}}public SqlDouble Terminate(){if (numValues == 0){return SqlDouble.Null;}else{return (this.totalValue / this.numValues);}}// private accumulatorsprivate int numValues;private SqlDouble totalValue;}[Serializable][Microsoft.SqlServer.Server.SqlUserDefinedAggregate (Format.Native)]public struct TrimmedAvg{public void Init(){this.numValues = 0;this.totalValue = 0;this.minValue = SqlDouble.MaxValue;this.maxValue = SqlDouble.MinValue;}public void Accumulate(SqlDouble Value){if (!Value.IsNull){this.numValues++;this.totalValue += Value;if (Value < this.minValue)this.minValue = Value;if (Value > this.maxValue)this.maxValue = Value;}}public void Merge(TrimmedAvg Group){if (Group.numValues > 0){this.numValues += Group.numValues;this.totalValue += Group.totalValue;if (Group.minValue < this.minValue)this.minValue = Group.minValue;if (Group.maxValue > this.maxValue)this.maxValue = Group.maxValue;}}public SqlDouble Terminate(){if (this.numValues < 3)return SqlDouble.Null;else{this.numValues -= 2;this.totalValue -= this.minValue;this.totalValue -= this.maxValue;return (this.totalValue / this.numValues);}}// private accumulatorsprivate int numValues;private SqlDouble totalValue;private SqlDouble minValue;private SqlDouble maxValue;}*/--Test #2--Scenario G - Average Query using built-in aggregate--SELECT ProductID, Avg(Cast(PercentPassed AS float))FROM TestAssignmentGROUP BY ProductIDORDER BY ProductID--Scenario H - Average Query using CLR aggregate--SELECT ProductID, dbo.Avg_CLR(Cast(PercentPassed AS float)) AS AverageFROM TestAssignmentGROUP BY ProductIDORDER BY ProductID--Scenario I - Trimmed Average Query using built in aggregates/setoperations--SELECT A.ProductID,CaseWhen B.CountValues<3 Then NullElse Cast(A.Total-B.MaxValue-B.MinValue ASfloat)/Cast(B.CountValues-2 As float)End AS AverageFROM(SELECT ProductID, Sum(PercentPassed) AS TotalFROM TestAssignmentGROUP BY ProductID) ALEFT JOIN(SELECT ProductID,Max(PercentPassed) AS MaxValue,Min(PercentPassed) AS MinValue,Count(*) AS CountValuesFROM TestAssignmentWHERE PercentPassed Is Not NullGROUP BY ProductID) BON A.ProductID=B.ProductIDORDER BY A.ProductID--Scenario J - Trimmed Average Query using CLR aggregate--SELECT ProductID, dbo.TrimmedAvg_CLR(Cast(PercentPassed AS real)) ASAverageFROM TestAssignmentGROUP BY ProductIDORDER BY ProductID
View 9 Replies View RelatedCan anyone please give me the equivalent tsql for sql server 2000 for the following two queries which works fine in sql server 2005
1
-- Full Table Structure
select t.object_id, t.name as 'tablename', c.name as 'columnname', y.name as 'typename', case y.namewhen 'varchar' then convert(varchar, c.max_length)when 'decimal' then convert(varchar, c.precision) + ', ' + convert(varchar, c.scale)else ''end attrib,y.*from sys.tables t, sys.columns c, sys.types ywhere t.object_id = c.object_idand t.name not in ('sysdiagrams')and c.system_type_id = y.system_type_idand c.system_type_id = y.user_type_idorder by t.name, c.column_id
2
-- PK and Index
select t.name as 'tablename', i.name as 'indexname', c.name as 'columnname' , i.is_unique, i.is_primary_key, ic.is_descending_keyfrom sys.indexes i, sys.tables t, sys.index_columns ic, sys.columns cwhere t.object_id = i.object_idand t.object_id = ic.object_idand t.object_id = c.object_idand i.index_id = ic.index_idand c.column_id = ic.column_idand t.name not in ('sysdiagrams')order by t.name, i.index_id, ic.index_column_id
This sql is extracting some sort of the information about the structure of the sql server database[2005]
I need a sql whihc will return the same result for sql server 2000
i have a table named table1 sitting on a a partittion scheme px.
table1 is partitioned on u_id by tens,
first partion u_id=0 to 9
second partion u_id=10 to 19
third partion u_id=20 to 29
ans so on and so forth
i have a table named table2 with
records having u_id = 13 to 16
obviously belonging to the second partion.
i want to load table2 to table1 as fast as i could with
the following requirements:
all contents of partition 2 of table1 must be deleted before loading
table2 ceases to exist after the operation
how will i do that.
thanks.
Hi All,
Can someone take a look at my code and tell me what i'm doing in wrong. The script runs fine but when i go to table property it says the table is not partitioned. Thanks for your help.
create database [mypartition]
go
--CREATE FILEGROUP
USE [mypartition]
GO
ALTER DATABASE mypartition ADD FILEGROUP Y2000_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2001_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2002_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2003_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2004_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2005_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2006_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2007_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2008_filegroup
ALTER DATABASE mypartition ADD FILEGROUP Y2009_filegroup
--CREATE FILES
USE mypartition
GO
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2000,
FILENAME = 'F:ss_datadatadetail_2000.ndf',
SIZE = 2MB)
TO FILEGROUP Y2000_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2001,
FILENAME = 'F:ss_datadatadetail_2001.ndf',
SIZE = 2MB)
TO FILEGROUP Y2001_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2002,
FILENAME = 'F:ss_datadatamdetail_2002.ndf',
SIZE = 2MB)
TO FILEGROUP Y2002_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2003,
FILENAME = 'F:ss_datadatadetail_2003.ndf',
SIZE = 2MB)
TO FILEGROUP Y2003_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2004,
FILENAME = 'F:ss_datadatadetail_2004.ndf',
SIZE = 2MB)
TO FILEGROUP Y2004_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2005,
FILENAME = 'F:ss_datadatadetail_2005.ndf',
SIZE = 2MB)
TO FILEGROUP Y2005_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2006,
FILENAME = 'F:ss_datadatadetail_2006.ndf',
SIZE = 2MB)
TO FILEGROUP Y2006_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2007,
FILENAME = 'F:ss_datadatadetail_2007.ndf',
SIZE = 2MB)
TO FILEGROUP Y2007_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2008,
FILENAME = 'F:ss_datadatadetail_2008.ndf',
SIZE = 2MB)
TO FILEGROUP Y2008_filegroup;
ALTER DATABASE mypartition
ADD FILE
(NAME = mypartition_detail_2009,
FILENAME = 'F:ss_datadatadetail_2009.ndf',
SIZE = 2MB)
TO FILEGROUP Y2009_filegroup;
--CREATE PARTITION FUNCTION
USE [mypartition]
GO
CREATE partition FUNCTION detail_part_function (varchar(10)) AS
RANGE LEFT FOR VALUES('2001','2002','2003','2004','2005','2006','2007','2008')
GO
--CREATE PARTITION SCHEME
USE [mypartition]
GO
CREATE PARTITION SCHEME detail_part_scheme AS
PARTITION detail_part_function TO
(Y2000_filegroup, Y2001_filegroup,Y2002_filegroup,Y2003_filegroup,Y2004_filegroup,Y2005_filegroup,Y2006_filegroup,Y2007_filegroup,Y2008_filegroup,Y2009_filegroup)
GO
-- Now just create a table that uses the particion scheme
USE [mypartition]
GO
/****** Object: Table [dbo].[partitioned_table] Script Date: 05/14/2008 09:44:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[partitioned_table](
[id] [int] NOT NULL,
[fiscal_year] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_partitioned_table] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON detail_part_scheme(fiscal_year)
GO
SET ANSI_PADDING OFF
I can see lot of documentation on Range Partitioning. Is there any other type of partition supported in SQL Server 2005?
For example, I have a Fact table having Billion rows. It has a column called BATCH_ID. A BATCH_ID corresponds to 10-20 Million rows and it is a running sequence number like 1,2,3 etc. (not an identity column). Is there anyway I can specify a partition function with BATCH_ID column as an int value? Will the SQL Server automatically does the partition on each int value in that case? If not, what is the best way to do it?
Thanks in advance for all help in this
Hi,
I recently installed MSSQL 2000 and sp3a onto a windows 2003 server in a test lab. I configured one big c: partion on this os and installed the db in the default location.
I need to detach the db's on this server and re-attach them onto another MSSQL 2000/sp3a server running 2003 os with a partition scheme like this:
c: = 20 gigs for the os
e: = 600 gigs for the data
I could not re-attach the db's onto the e:default path odatabase
Is there a work-around for this? This makes sense to me as to why it is not working and was an install oversight on my part but there has to be a way to overcome this delima?
Thanks in advance,
damnit
Hi
Please help me how to do the Horizontal table partition??
I have to split the table in to multiple sub tables with same columns and less rows and then I have to use each sub table.
Thanks you in advance....
Regards
LakshmiPK
Hi everybody
Does anyone know where I can find code to PROCESS a Partition using DSO.
Thank a lot.
I keep getting this error:
Msg 156, Level 15, State 1, Line 12
Incorrect syntax near the keyword 'over'.
What am I missing? The max() over statement looks just like the statement in the documentation.
select RegistrationId,
OrderId,
Sequence,
Title,
InformalFirstName,
FirstName,
MiddleName,
Lastname,
EntryDate,
max(Sequence) over(partition by RegistrationId) as 'maxsequence'
from registration
where OrderId = '68379449583' and
Year = '2008' and
Active = 'Yes'
I have a situation where my SQL works everywhere else but my COBOL compiler complains wherever I use PARTITION BY. I can't find a workaround for that problem so I would like to remove all the PARTITION BYs. I'm not confident that I can do this accurately and would like some help getting started.
Here is my simplest example:
SELECT FESOR.REGION, FESOR.TYPE,
COUNT(*) OVER (PARTITION BY FESOR.REGION, FESOR.TYPE)
FROM FESOR, FR
where FESOR.phase = 'Ref'
and FESOR.assign is null
and FESOR.comp_date is null
and FESOR.region = FR.REGION
and FESOR.type = FR.TYPE
and FR.REP_ROW='A'
GROUP BY FESOR.REGION, FESOR.TYPE
What I'm looking for is a modified version of the SQL above which returns the same result set without using PARTITION BY.
Thanks in advance for your assistance.
Hi,
I am using SQL Server 2000 SP3 Version 8.00.7.60. Can I create instances of SQL server 2000 even if it's already installed?
Thanks for your help in advance!
Guys,
I have names in the database which I want partition by last name - for example last names starting with A, B, C, D should go to the file group 1. last names starting with E, F, G, H should go to file group 2.
I am trying to use the following function - but do I specify in the function that last names with with A, B, C, D should go to the file group 1
CREATE PARTITION FUNCTION myRangePF3 (char(20))
AS RANGE RIGHT FOR VALUES ('EX', 'RXE', 'XR');
Is there any way to modify partition function to accomplish this?
Any suggestions and inputs would help
Thanks
All,
I have a partitioned table (1.7 billion rows) that is across 97 partions. The table is partitioned on datetime field.
When I query only this table with datetime field in where clause I see that cleary it outperforms the unpartitioned table.
When this table is joined to 3 tables it performs no better than
the non-partitioned table... it seems that the query does a partition scan.
The part. table has a 3 part composite clustered index and
a NC index on the partion field value.
Would appreciate any feedback.
thanks
SUM(qtycolumn) OVER (PARTITION BY columnA, Column B)
is this function supported by Sql Ce?
HI all,
I am in the progress of migrating my 2000 install over to SQL05 and onto a couple of new boxes. I have 2 Dell 1850's to set up mirroring on and wanted to know your opinion on the best partition setup. The 1850's are a 2 disk machine so it has to be a RAID 1 setup. I am just unsure of the benefit of partitioning the logical drive to seperate the log files from the data files.
Should I partition the drive, a 300G SCSI into 2 partitions and keep the logs on one partition and the data on another? Can anyone tell me if there is a benefit to doing this?
If there is a more pratical solution can you explain?
Thanks in advance!
Jason
Sydney Australia
Most examples for SQL Server 2005 involve a sales table that you split based on date, i.e. sales records prior to 2000 go to this partition, and the ones after that go to another one. Nice and simple.
Say I have a sales table:
id Amount Date
1 10 1/1/1999
2 9.99 1/1/2007
Now then, I put all the records prior to 2000 in it's own partition.
So when I do something like this: SELECT * FROM Sales WHERE DATE = 1/1/1999
the SQL server will know which partition to look at. Very nice.
Now then, if I do this: SELECT * FROM Sales WHERE id = 1
How will the SQL server know which partition to look at?
Thank You!
hi list
i have a table named stgBudgetFact, that is partitioned on DivisionID.
each DivisionID goes into its own partition, which is on its own file group.
the etl guru on the project wants to be able to truncate the partition, not do a delete from the table based on DivisionID.
Is it possible to truncate the partition somehow (remove rows where DivisionID = 3 for instance without ALTER DATABASE, where the medicine is worse than the disease) and then reestablish the partition so we can restart a failed load by division?
i really hope something like this is possible
thanks
drew
hello,
I want to copy all or part data in one partition to another partition,how can I do?
Dear all,
Sorry if my post misplaced. I have a table that contain huge data so I made a partition function and partition schema. Unfortunately there's only one column to be allowed as a partition column whereas my queries using a few columns. Can we make many partition function that apply to one partition schema ? I search no result in SQL BOL.
Thanks in advance.
Best regards,
Hery
Hi Every body,
I am creating Table partition in tables but i am getting this error can you anybody plz help how can we do table partition in the database
CREATE TABLE PartitionTable (col1 int, col2 char(10))
ON myRangePS2 (col1) ;
GO
CREATE TABLE NonPartitionTable (col1 int, col2 char(10))
ON test2fg1 ;
GO
ALTER TABLE PartitionTable SWITCH PARTITION 2 TO NonPartitionTable ;
GO
Msg 1921, Level 16, State 1, Line 2
Invalid partition scheme 'myRangePS2' specified.
Msg 1921, Level 16, State 1, Line 1
Invalid filegroup 'test2fg1' specified.
Msg 4902, Level 16, State 1, Line 1
Cannot find the object "PartitionTable" because it does not exist or you do not have permissions.
Does anyone know how much free space should be left available on a storage partition to allow for the optimum performance? In fact is there any performance benefit to allowing a certain amount of free space on a partition that is occupied by SQL data files?
How complex can the over (partition by...) window functions be? All the examples I see in BoL, the partition clause is the same for each window function. Can it be different? How different?
Here are some snippets of where I'd like to take this. Right now I'm using successive views to bring the results to a single row.
SUM(building_function_table.e_and_g_square_foot + building_function_table.auxillary_square_foot)
OVER (PARTITION BY building_function_table.fice_code, building_function_table.building_number) AS sqft
SUM(building_function_table.e_and_g_square_foot * function_table.square_foot_value)
OVER (PARTITION BY building_function_table.fice_code, building_function_table.building_number,building_function_table.function_code) AS repl_value_e_g
SUM(building_needs_table.percentage * (building_needs_table.age / system_component_table.useful_life) * component_multiplier_table.multiplier)
OVER (PARTITION BY building_needs_table.fice_code, building_needs_table.building_number, building_needs_table.system_code, building_needs_table.system_component_code, building_needs_table.function_code) as maint_needs
And it gets even more complex, but these are all I've written because I don't know if it will work.
These would be all part of a giant overhead view of a building maintenance database. It's normalized and the respective tables above are all simple inner joins on the primary key of their parent.
1 HIS_HTTP_LOG a partition table2 REL_HTTP_LOG not a partition table,the same structure of HIS_HTTP_LOGļ¼3 When HIS_HTTP_LOG doesn't exist any index the following executed succeed
ALTER PARTITION SCHEME PS_HIS_HTTP_LOG NEXT USED [FG_03] ALTER PARTITION FUNCTION PF_HIS_HTTP_LOG() SPLIT RANGE ('20070331 23:59:59.997') ALTER TABLE TMP_HTTP_LOG SWITCH TO HIS_HTTP_LOG PARTITION 3
4 However when I added the index in HIS_HTTP_LOG and execute the step 3,It made error: a) CREATE INDEX IDX_HIS_HTTP_LOG_001 ON HIS_HTTP_LOG(USERID)ON PS_HIS_HTTP_LOG (STARTIME) b) ALTER PARTITION SCHEME PS_HIS_HTTP_LOG NEXT USED [FG_03] ALTER PARTITION FUNCTION PF_HIS_HTTP_LOG() SPLIT RANGE ('20070331 23:59:59.997') ALTER TABLE TMP_HTTP_LOG SWITCH TO HIS_HTTP_LOG PARTITION 3
========================= Error messages================================================"ALTER TABLE SWITCH statement failed. There is no identical index in source table 'TMP_HTTP_LOG SWITCH ' for the index 'IDX_HIS_HTTP_LOG_001' in target table 'HIS_HTTP_LOG' ."
When I added index in REL_HTTP_LOG ,it gave me the same error message
Could you tell me how can I solve the problem !
I have the pagefile.sys on the same partition (C:)as the database files. I been advised this is not a good idea. I'm getting paging. I'd like to move the swapfile to another partition on the same drive. Is that a good idea, or should I move it to another physical disk? And is it OK to leave the OS partition (C:) without any swapfile? Thanks!!
rob
Does anyone know who can we do partition od table in sqlserve 7?
View 3 Replies View RelatedHi!
I'm installing a new SQL Server machine. During NT Server
installation our NT support guy converted the only 2GB FAT
C: partition to NTFS. So as of right now all my 4 8GB drives are
NTFS. I think it would be better to keep this C: partition in FAT
because, as of my knowledge, having FAT boot partition can help
to boot the machine in case of NT crash.
Is there anything that I'm really losing by this conversion to NTFS or I
should not be worried so much about it? Does it put my SQL Server
databases, database .dat files or NT Server in more danger situation
in case of any crash?
Or it's giving me some advantages?
Thanks
Ninel
Hi folks,
Recently i've been working on a new project that would partition a large table 2 smaller tables. I then create a view to union the 2 smaller tables(table A, B). I've been getting a strange error when i try to update, insert, delete a record through the view. "View needs partitioning column"....i find this strange. Both of my table have a cluster primary key consisting of 3 columns, and one of the 3 columns(date field) consist of a check constraint. The constraint is used to determine what record goes into which table. Am i missing anything else? The really strange part is sometime it works, and sometimes i get the error message.
Any thoughts?
Joe R.
If I have a table split up among partitions A, B, C, how do I select only from partition C?
~Le
I need to create a new partition on a Cube using T-SQL and I am not much aware of either the Cubes or the ActiveX script. I am writing a T-SQL script for creating this partition on a cube.
Select Case iMonth
Case 1,2,3
sQuarter = "1"
Case 4,5,6
sQuarter = "2"
Case 7,8,9
sQuarter = "3"
Case 10,11,12
[Code] .....
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