Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Tuesday, March 27, 2012

Can I generate Table Script in a Stored Procedure?

I have to load around 40 tables and I want to write one Stored Procedure that I pass a table name into. Data is coming from 3 different sources and to fill each of the 40 tables. I want to create a temp table that I can load first to make sure it succeeds first before I truncate and insert into the production table.

Is there a system procedure or something that will allow me to create a temp table from a table that alresdy exist in my database?

You can use SELECT INTO to create a new table based on a query like:

SELECT t.col1, t.col2, t.col3

INTO #t

FROM your_table AS t

Above query will create table with same structure as your_table without the defaults, constraints, indexes etc. Identity property on columns will be transferred though. You may also want to look at SSIS to automate your bulk loading process. You can also take a look at the link below for more pointers on how to improve the bulk load process:

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/incbulkload.mspx

Note that with above query, you can create permanent table too. If you create a temporary table then you can only use BULK INSERT statement since the temporary table is connection scoped. And I am not sure if SSIS can perform SELECT...INTO and bulk load from the client side within context of single connection (You will have to ask in the SSIS forum).

|||

Good to know you can create Temps like this.

I might be able to work with this let me know what you think.

Problem:

I’m getting my data from an AS400 using

Insert Into @.TableName

Select *

from Opendatasource(“Connection Info”).AS400ServerName.AS400Library.@.TableName

The table name and column structure in the AS400 are the same as in my database but the column type is different i.e. A lot of the AS400 columns are Char when I need them to be Decimal. I need to create the temp table with the same structure as my table because the majority of the time my process fails is because the AS400 has Char data when it should be Decimal

My Solution:

Select Top 1 *

Into #t

From @.TableName

Truncate Table #t

--Insert temp data from sites

Insert Into #t

Select *

from Opendatasource(“Connection Info”).AS400ServerName.California.@.TableName

Insert Into #t

Select *

from Opendatasource(“Connection Info”).AS400ServerName.Nevada.@.TableName

Insert Into #t

Select *

from Opendatasource(“Connection Info”).AS400ServerName.Arizona.@.TableName

Truncate Table @.TableName

--Insert data to Production

Insert Into @.TableName

Select *

From #t

Wednesday, March 7, 2012

can clustering use as load balacing

I want to have 3 MSSQL server that work at same time on shared
database(all opened a single data file on SAN for example). And request
for queries are send to those parallel and same sql servers to archive
more processing power and fail over feature?act as load balancing?
what can I do for load balancing heavy traffic queries like which can
done on web server?
thanks
SQL Server does not support shared-disk clustering for load balancing, though
there is a feature in SQL2005 called scalable shared database that allows you
to present the same database via a LUN to multiple SQL2005 instances for
read-only access.
Linchi
"Tarvirdi" wrote:

> I want to have 3 MSSQL server that work at same time on shared
> database(all opened a single data file on SAN for example). And request
> for queries are send to those parallel and same sql servers to archive
> more processing power and fail over feature?act as load balancing?
> what can I do for load balancing heavy traffic queries like which can
> done on web server?
> thanks
>
|||Linchi Shea wrote:
> SQL Server does not support shared-disk clustering for load balancing, though
> there is a feature in SQL2005 called scalable shared database that allows you
> to present the same database via a LUN to multiple SQL2005 instances for
> read-only access.
Dear Linchi,
Thanks for your response.
What you mean about sharing datafile?
For example I have A database named T1 with T1.mdf and want to have
another Database on other server(or same server to start test) and have
read only access to above T1.mdf? how implement it? which steps should I do?
I tried but failed because of "can create already exist file error"
Thanks
|||
> For example I have A database named T1 with T1.mdf and want to have
> another Database on other server(or same server to start test) and have
> read only access to above T1.mdf?
You can not do this
The limitation is NTFS, NTFS you can only have on server accessing the
volume at a time.
You can not do this on the same host either as SQL will have a problem
(cache comes to mind first)
the answer to your original question:
Q: can clustering be used as load balancing for SQL ?
A: no
|||
> there is a feature in SQL2005 called scalable shared database that allows
you
> to present the same database via a LUN to multiple SQL2005 instances for
> read-only access.
correct, but that is a "static" disk, presented RO to multiple hosts
you cannot have one host "writing" to and others "reading" from the same
disk

Saturday, February 25, 2012

Can anyone help me with connecting to a database to search?

I'm trying to make this piece of code work, I get all of it except how I get the data from the database, what I wish to do is. On page load I wish to take the value of a querystring in the page URL called ProductID and search a database to see if it exists in a specifical table and column, if it exists I wish to make a button not visible. the code I am using is:

#############

protectedvoid Page_Load(object sender,EventArgs e)

{

// Get the querystring value

String inQueryString = Request.QueryString["ProductID"];

// Get the data from the database, using the above value

DataTable data = ??

The datasource I want to connect to is SqlDataSource1, and the table I want to search is "Reviews". I want to search in the column "ProductID" and search for the ProductID from the URL query string above.

// Did we find a product in the database?

if (data !=null &&

data.Rows.count > 0)

{

// Code to display the product's information

// We found a product, so we need to hide a button

Button5.Visible =false;

}

}

##########################

Please can somebody fill in the missing bit for me so i know how it should be, i've searched the quickstart tutorial on the menu above and I still don't understand it, as it doesn't show anything like what I want to do, and I have looked at numerous websites about the matter. If you don't have time that is okay, but If somebody does have the time to show me what I need, I would be very greatfull.

Regards

Daniel coates

anyone got any ideas? surely somebody must know what I need to do!

Regards

Dan