Showing posts with label insert. Show all posts
Showing posts with label insert. Show all posts

Tuesday, March 27, 2012

Creating xsd schema file for a xml file ...

Hi ...
I need to bulk insert the xml data below. I am working on some issues related to the Itentity column (you may have read the other question).
The xml below uses elements with attributes. Is the schema file formated correctly to extract the attributes from the SITE element and then also extract the attributes from the ATMOSPHERIC element ... ? Not sure about the schema file ?
Thanks,
Chris

////////////////////////////////////////////////////
// schema file
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="site" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="sysid" type="xsd:string" sql:field="SystemId"/>
<xsd:attribute name="rpuid" type="xsd:string" sql:field="RpuId"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="atmospheric" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="datetime" type="xsd:date" sql:field="ObsDateTime"/>
<xsd:attribute name="airtemp" type="xsd:string" sql:field="Temperature"/>
<xsd:attribute name="dewpoint" type="xsd:string" sql:field="DewPoint"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>

////////////////////////////////////////////////////
// xml data
<?xml version="1.0"?>
<odot_rwis_site_info>
<site id="200000" number="1" sysid="200" rpuid="0" name="1-SR127 @. SR249" longitude="-84.554946" latitude="41.383527">
<atmospheric datetime="12/05/2005 03:48:00 PM" airtemp="-490" dewpoint="-800" relativehumidity="73" windspeedavg="11" windspeedgust="19" winddirectionavg="265" winddirectiongust="295" pressure="65535" precipitationintensity="None" precipitationtype="None" precipitationrate="0" precipitationaccumulation="-1" visibility="2000" />
<sensors>
<surface id="0" datetime="12/05/2005 03:48:00 PM" name="North Bound Driving Lane" surfacecondition="Dry" surfacetemp="1900" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="450" waterlevel="0">
<traffic datetime="12/05/2005 03:48:00 PM" occupancy="0" avgspeed="82" volume="21" sftemp="1900" sfstate="255">
<normalbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="0" bincount="7" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="1" bincount="0" />
</normalbins>
<longbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="2" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="3" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="4" bincount="1" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="5" bincount="0" />
</longbins>
</traffic>
</surface>
<surface id="1" datetime="12/05/2005 03:48:00 PM" name="Bridge Deck Simulator" surfacecondition="Other" surfacetemp="-60" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="-999999" waterlevel="0" />
</sensors>
</site>
</odot_rwis_site_info>

////////////////////////////////////////////////////
// table
CREATE TABLE [MacgowanTestRWISRawAtmospheric] (
[RecordId] [int] IDENTITY (1, 1) NOT NULL ,
[DataSourceId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_DataSourceId] DEFAULT ('OH'),
[ProductInstanceId] [char] (38) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_ProductInstanceId] DEFAULT ('5abbbc86-fb2c-4703-9589-b55f763ee150'),
[SystemId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[RpuId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[SensorId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ObsDateTime] [datetime] NULL ,
[InsertDateTime] [datetime] NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_InsertDateTime] DEFAULT (getdate()),
[Temperature] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DewPoint] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[RelativeHumidity] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPD] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPDGust] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMin] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRAvg] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMax] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipIntensity] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipType] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipRate] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Pressure] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Visability] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMax] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMin] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WetBulbTemp] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LastPrecipStart] [datetime] NULL ,
[LastPrecipEnd] [datetime] NULL ,
[PrecipAccum1Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum3Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum6Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum12Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum24Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_MacgowanTestRWISRawAtmospheric] PRIMARY KEY NONCLUSTERED
(
[RecordId]
) WITH FILLFACTOR = 70 ON [PRIMARY]
) ON [PRIMARY]
GO

Not sure if I understand the question fully. Are you having any specific issues with bulk loading this data? or the issue is validating your XML data against XSD?

thanks

|||Hi ...

Sorry about the confusion. I was having some issues with bulk

loading using the IDENTITY Column in the target table. I was

setting the COM attribute KeepIdentity to TRUE rather than FALSE.

The schema and xml are correct.

Thanks,

Chris

Creating xsd schema file for a xml file ...

Hi ...
I need to bulk insert the xml data below. I am working on some issues related to the Itentity column (you may have read the other question).
The xml below uses elements with attributes. Is the schema file formated correctly to extract the attributes from the SITE element and then also extract the attributes from the ATMOSPHERIC element ... ? Not sure about the schema file ?
Thanks,
Chris

////////////////////////////////////////////////////
// schema file
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="site" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="sysid" type="xsd:string" sql:field="SystemId"/>
<xsd:attribute name="rpuid" type="xsd:string" sql:field="RpuId"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="atmospheric" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="datetime" type="xsd:date" sql:field="ObsDateTime"/>
<xsd:attribute name="airtemp" type="xsd:string" sql:field="Temperature"/>
<xsd:attribute name="dewpoint" type="xsd:string" sql:field="DewPoint"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>

////////////////////////////////////////////////////
// xml data
<?xml version="1.0"?>
<odot_rwis_site_info>
<site id="200000" number="1" sysid="200" rpuid="0" name="1-SR127 @. SR249" longitude="-84.554946" latitude="41.383527">
<atmospheric datetime="12/05/2005 03:48:00 PM" airtemp="-490" dewpoint="-800" relativehumidity="73" windspeedavg="11" windspeedgust="19" winddirectionavg="265" winddirectiongust="295" pressure="65535" precipitationintensity="None" precipitationtype="None" precipitationrate="0" precipitationaccumulation="-1" visibility="2000" />
<sensors>
<surface id="0" datetime="12/05/2005 03:48:00 PM" name="North Bound Driving Lane" surfacecondition="Dry" surfacetemp="1900" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="450" waterlevel="0">
<traffic datetime="12/05/2005 03:48:00 PM" occupancy="0" avgspeed="82" volume="21" sftemp="1900" sfstate="255">
<normalbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="0" bincount="7" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="1" bincount="0" />
</normalbins>
<longbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="2" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="3" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="4" bincount="1" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="5" bincount="0" />
</longbins>
</traffic>
</surface>
<surface id="1" datetime="12/05/2005 03:48:00 PM" name="Bridge Deck Simulator" surfacecondition="Other" surfacetemp="-60" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="-999999" waterlevel="0" />
</sensors>
</site>
</odot_rwis_site_info>

////////////////////////////////////////////////////
// table
CREATE TABLE [MacgowanTestRWISRawAtmospheric] (
[RecordId] [int] IDENTITY (1, 1) NOT NULL ,
[DataSourceId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_DataSourceId] DEFAULT ('OH'),
[ProductInstanceId] [char] (38) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_ProductInstanceId] DEFAULT ('5abbbc86-fb2c-4703-9589-b55f763ee150'),
[SystemId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[RpuId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[SensorId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ObsDateTime] [datetime] NULL ,
[InsertDateTime] [datetime] NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_InsertDateTime] DEFAULT (getdate()),
[Temperature] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DewPoint] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[RelativeHumidity] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPD] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPDGust] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMin] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRAvg] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMax] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipIntensity] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipType] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipRate] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Pressure] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Visability] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMax] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMin] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WetBulbTemp] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LastPrecipStart] [datetime] NULL ,
[LastPrecipEnd] [datetime] NULL ,
[PrecipAccum1Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum3Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum6Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum12Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum24Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_MacgowanTestRWISRawAtmospheric] PRIMARY KEY NONCLUSTERED
(
[RecordId]
) WITH FILLFACTOR = 70 ON [PRIMARY]
) ON [PRIMARY]
GO

Not sure if I understand the question fully. Are you having any specific issues with bulk loading this data? or the issue is validating your XML data against XSD?

thanks

|||Hi ...
Sorry about the confusion. I was having some issues with bulk loading using the IDENTITY Column in the target table. I was setting the COM attribute KeepIdentity to TRUE rather than FALSE.
The schema and xml are correct.
Thanks,
Chris

Thursday, March 22, 2012

Creating Test Data for a Table

Hello, say I have a Table with 2 columns:

integer ID

varchar Description

How can I insert a large number of test rows inside this table for experimentation purposes?

Thanx in advance!

u can use some existing table...transform and import that data...

or..there are a few data generator tools u can search and use them.... if u have visual studio 2005 for database developer, that has a cool data generation functionality too...

|||

Thanx, though I was looking for a T-SQL query equivalent solution

Maybe a while loop? I'm not so good at writing code in sql, any other suggestions please?

|||

JohDas wrote:

Hello, say I have a Table with 2 columns:

integer ID

varchar Description

How can I insert a large number of test rows inside this table for experimentation purposes?

Thanx in advance!

INSERT INTO
MyTable (id, Description)
(
SELECT
Id, Description
FROM
MyOtherTable
)|||

The following query may help you..

Create Table TestTable
(
Id int,
Description varchar(100)
)
go
SET NOCOUNT ON
Declare @.Count as int
Select @.Count = 10000
While @.Count >0
Begin
Insert Into TestTable values (@.Count, 'Description ' + Convert(Varchar,@.Count));
Select @.Count = @.Count - 1
End

You can change your Count init value as you want upto 2,147,483,647 ..

|||

ManiD wrote:

The following query may help you..

Create Table TestTable
(
Id int,
Description varchar(100)
)
go
SET NOCOUNT ON
Declare @.Count as int
Select @.Count = 10000
While @.Count >0
Begin
Insert Into TestTable values (@.Count, 'Description ' + Convert(Varchar,@.Count));
Select @.Count = @.Count - 1
End

You can change your Count init value as you want upto 2,147,483,647 ..

Nice, after seeing this I realised I mis understood the question |||Thanx a lot, this is the query I've been searching!!!|||

JohDas:

I try to avoid these WHILE loops as much as possible. I normally try to use a "numbers" table to generate my test data; this is normally much more efficient. One of the tools that I find helpful for generating repetitive data is the modulo "%" operator

-- --
-- Give a look to this link for a description of the use of a
-- "numbers" table:
--
-- http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-numbers-table.html
--
-- A table that can be used on a "test only" basis is the
-- "master.dbo.spt_values" table; but be forwarned: this type
-- of use is not supported! In fact, if you use this table with
-- SQL Server 2000 you will find that you get a different range
-- of values for the "number" column than you do with SQL Server
-- 2005.
--
-- Nonetheless, I still frequently use this table as a source of
-- values for test data. If the range of values from this table
-- is not sufficient to provide enough data, then I might
-- generate my data by cross joining the spt_values table with
-- itself.
-- --
select number,
'Description #' + convert (varchar(10), number%21) Description
from master.dbo.spt_values (nolock)
where name is null

-- Output:

-- number Description
-- -- --
-- 0 Description #0
-- 1 Description #1
-- 2 Description #2
-- ...
-- 20 Description #20
-- 21 Description #0
-- 22 Description #1
-- ...

|||

Thanx Mugambo, it's a more complex solution (to comprehend ;) ) but I think it'll be faster

Creating Tables with Triggers

I need an Insert trigger to create a set of tables to my database when i add
new record in the top level master table (horizontal partitioning
denormalization)..
Is this possible using trigger or procedure or even function' and how'
any help appreciated.I'd doing such things by using stored procedure rather within a trigger
Identify that row has beed added and call SP to create a table
"Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
news:OI%23fdSb7FHA.1416@.TK2MSFTNGP09.phx.gbl...
>I need an Insert trigger to create a set of tables to my database when i
>add new record in the top level master table (horizontal partitioning
>denormalization)..
> Is this possible using trigger or procedure or even function' and how'
> any help appreciated.
>|||As I said in my other post:
1) Don't multi-post.
2) This is a bad design.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
news:OI%23fdSb7FHA.1416@.TK2MSFTNGP09.phx.gbl...
>I need an Insert trigger to create a set of tables to my database when i
>add new record in the top level master table (horizontal partitioning
>denormalization)..
> Is this possible using trigger or procedure or even function' and how'
> any help appreciated.
>|||1) I said sorry for posting in 2 groups..
2) there was no reply to my first thread and i'm in need to help
3) Why u think it's a bad design' How gcould i design something better'
hope u could help
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uT635Kc7FHA.1000@.tk2msftngp13.phx.gbl...
> As I said in my other post:
> 1) Don't multi-post.
> 2) This is a bad design.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> "Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
> news:OI%23fdSb7FHA.1416@.TK2MSFTNGP09.phx.gbl...
>|||How could i write a procedure to create table "Table_[ID]" Where id is a
paramter..
Also i must use trigger anyway to call this proccedure right'
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uS5H77b7FHA.3044@.TK2MSFTNGP10.phx.gbl...
> I'd doing such things by using stored procedure rather within a trigger
> Identify that row has beed added and call SP to create a table
>
> "Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
> news:OI%23fdSb7FHA.1416@.TK2MSFTNGP09.phx.gbl...
>|||You'll have to be patient. Participation in these groups is voluntary. If
you want immediate help, then open a ticket with PSS.
As for the design, you will have a proliferation of tables, which will be
difficult to control. Why is it that you need all of these tables? Why
can't you have a single table with a column that differentiate? How about
providing a clear business spec - not a program spec?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
news:eOhRFGd7FHA.956@.TK2MSFTNGP10.phx.gbl...
> 1) I said sorry for posting in 2 groups..
> 2) there was no reply to my first thread and i'm in need to help
> 3) Why u think it's a bad design' How gcould i design something better'
> hope u could help
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:uT635Kc7FHA.1000@.tk2msftngp13.phx.gbl...
>|||Thanx for inform me about PSS ticket and sorry for multi-post.
I need to have many tables coz one table will hv more than 6,000,000 record
with 2 text fields one of them is type of "text". which mean searching is so
slow.. so partitioning tables will make each table contain 100,000 to
600,000 record which give reliable search preformance specially with joins
and relations..
The business is database of counties laws and rules, and logically one will
search laws by country, so i partition my tables depend on the the country.
What do u think' do you have better idea'
P.S.. My text is in Arabic so Full Text indexing do not help..
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:ejgvjdd7FHA.2716@.TK2MSFTNGP11.phx.gbl...
> You'll have to be patient. Participation in these groups is voluntary.
> If you want immediate help, then open a ticket with PSS.
> As for the design, you will have a proliferation of tables, which will be
> difficult to control. Why is it that you need all of these tables? Why
> can't you have a single table with a column that differentiate? How about
> providing a clear business spec - not a program spec?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> "Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
> news:eOhRFGd7FHA.956@.TK2MSFTNGP10.phx.gbl...
>|||SQL Server can handle tables of billions of rows. Typically, you'd place
the text in a separate table, with a FK to the parent. You can place a
Country and County FK column on the parent and index those.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
news:%23gk6Brd7FHA.2432@.TK2MSFTNGP10.phx.gbl...
> Thanx for inform me about PSS ticket and sorry for multi-post.
> I need to have many tables coz one table will hv more than 6,000,000
> record with 2 text fields one of them is type of "text". which mean
> searching is so slow.. so partitioning tables will make each table contain
> 100,000 to 600,000 record which give reliable search preformance specially
> with joins and relations..
> The business is database of counties laws and rules, and logically one
> will search laws by country, so i partition my tables depend on the the
> country.
> What do u think' do you have better idea'
> P.S.. My text is in Arabic so Full Text indexing do not help..
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:ejgvjdd7FHA.2716@.TK2MSFTNGP11.phx.gbl...
>|||this drive to 2 big tables the parent one, and text table one.. this is the
current database structure which need 4 -5 min to search in the text..
this is time isn't acceptable so i will partitioning it to tables which cut
search time to 15 - 30 second (i tested it)
this is big improvment in time.
what do u think'
also could you plz tell me how could i use triggers to create these tables'
thanx
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:eiwD66d7FHA.2012@.TK2MSFTNGP14.phx.gbl...
> SQL Server can handle tables of billions of rows. Typically, you'd place
> the text in a separate table, with a FK to the parent. You can place a
> Country and County FK column on the parent and index those.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> "Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
> news:%23gk6Brd7FHA.2432@.TK2MSFTNGP10.phx.gbl...
>|||> "Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
> news:%23gWgQfe7FHA.1416@.TK2MSFTNGP09.phx.gbl...

> this drive to 2 big tables the parent one, and text table one.. this is
> the current database structure which need 4 -5 min to search in the text..
> this is time isn't acceptable so i will partitioning it to tables which
> cut search time to 15 - 30 second (i tested it)
Correct indexing will serve you much better than partitioning the table.
Create an index on whatever attribute you would otherwise partitrion the
table by and search on that as well as your other criteria. If "search in
the text" means a free text search then also take a look at the "Full-text
indexing" topics in Books Online. If you look at your earlier thread on this
topic I also made some other suggestions.
David Portas
SQL Server MVP
--

Sunday, February 19, 2012

Creating insert scripts from tables

Hi,

A seemingly simple question: How do I create an Insert script from the data of a selected number of tables in a given database?

(The Insert script has to be part of a deployment phase)

Esben

check whether this helps u

http://vyaskn.tripod.com/code/generate_inserts.txt

http://vyaskn.tripod.com/code.htm#inserts

Madhu

|||

http://vyaskn.tripod.com/code.htm#inserts

Jens K. Suessmeyer.


http://www.sqlserver2005.de

Friday, February 17, 2012

Creating FilePath for a BULK INSERT SP

Hi

I am creating an SP that will bulk insert data, the person calling the SP just needs to provide the file path and a number for the file and then the idea is i append this together to get the file to insert.

I have the SQL below which will not go past the BULK INSERT it is to do with my FilePath can anyone explain how I should be typing this?

Thanks very much

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go

CREATE PROCEDURE [dbo].[Get_DataFromFiles]

(

@.FileNumber VarCHAR(255),

@.FileID INT

)

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SET NOCOUNT ON;

--

-- 1. Insert Tasks Table Data and obtain the new ID

--

BULK INSERT Tasks FROM @.FilePath + 'FileNumber' + @.FileID WITH (FIELDTERMINATOR = '<$%^&>')

declare @.sql varchar(8000)
select @.sql = 'BULK INSERT Tasks FROM ' + @.FilePath + 'FileNumber' + @.FileID + ' WITH (FIELDTERMINATOR = ''<$%^&>'')'

exec (@.sql)|||

No but I forgot to show the backslash in the code i posted should read

select @.sql = 'BULK INSERT Tasks FROM ' + @.FilePath + '\FileNumber' + @.FileID + ' WITH (FIELDTERMINATOR = ''<$%^&>'')'

I still get an error though which is

Incorrect syntax near '@.FilePath'

|||Thanks for your help didnt realise I had to build the statement then execute it rather than just build as needed. Much appreciated.

Tuesday, February 14, 2012

Creating DDL (create statements) and data (insert satement)

Hi,
I have about 10.000 rows of data to be copied to another server in another
city, I want to create a DDL (create statements) and data (insert
statements) via EM but I only get the DDL. How to create the insert
statement from EM? There's such a feature? Or should I create it from app?
TIA,
Hendrickhttp://vyaskn.tripod.com/code/generate_inserts.txt
David Portas
SQL Server MVP
--|||http://vyaskn.tripod.com/code/generate_inserts.txt
will do it. However, for 10K rows it might be easier and more efficient
to use BCP. 10,000 individual INSERTs in a script could be a slow and
cumbersome process.
David Portas
SQL Server MVP
--|||Great, thanks.
We'll consider the BCP utililty, too.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1131038250.883762.17220@.f14g2000cwb.googlegroups.com...
> http://vyaskn.tripod.com/code/generate_inserts.txt
> will do it. However, for 10K rows it might be easier and more efficient
> to use BCP. 10,000 individual INSERTs in a script could be a slow and
> cumbersome process.
> --
> David Portas
> SQL Server MVP
> --
>

Creating DDL (create statements) and data (insert satement)

Hi,
I have about 10.000 rows of data to be copied to another server in another
city, I want to create a DDL (create statements) and data (insert
statements) via EM but I only get the DDL. How to create the insert
statement from EM? There's such a feature? Or should I create it from app?
TIA,
Hendrick
http://vyaskn.tripod.com/code/generate_inserts.txt
David Portas
SQL Server MVP
|||http://vyaskn.tripod.com/code/generate_inserts.txt
will do it. However, for 10K rows it might be easier and more efficient
to use BCP. 10,000 individual INSERTs in a script could be a slow and
cumbersome process.
David Portas
SQL Server MVP
|||Great, thanks.
We'll consider the BCP utililty, too.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1131038250.883762.17220@.f14g2000cwb.googlegro ups.com...
> http://vyaskn.tripod.com/code/generate_inserts.txt
> will do it. However, for 10K rows it might be easier and more efficient
> to use BCP. 10,000 individual INSERTs in a script could be a slow and
> cumbersome process.
> --
> David Portas
> SQL Server MVP
> --
>

Creating DDL (create statements) and data (insert satement)

Hi,
I have about 10.000 rows of data to be copied to another server in another
city, I want to create a DDL (create statements) and data (insert
statements) via EM but I only get the DDL. How to create the insert
statement from EM? There's such a feature? Or should I create it from app?
TIA,
Hendrickhttp://vyaskn.tripod.com/code/generate_inserts.txt
--
David Portas
SQL Server MVP
--|||http://vyaskn.tripod.com/code/generate_inserts.txt
will do it. However, for 10K rows it might be easier and more efficient
to use BCP. 10,000 individual INSERTs in a script could be a slow and
cumbersome process.
--
David Portas
SQL Server MVP
--|||Great, thanks.
We'll consider the BCP utililty, too.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1131038250.883762.17220@.f14g2000cwb.googlegroups.com...
> http://vyaskn.tripod.com/code/generate_inserts.txt
> will do it. However, for 10K rows it might be easier and more efficient
> to use BCP. 10,000 individual INSERTs in a script could be a slow and
> cumbersome process.
> --
> David Portas
> SQL Server MVP
> --
>