Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Thursday, March 29, 2012

How remove all quote characters in a sql table?

Hi

I have a table with a few hundred emailadresses. How can I delete all quotes (') from the addresses, so that'email@.email.com' is replaced asemail@.email.com.

Thank you

zipfeli

You can use the REPLACE Function. And you want to an UPDATE not a DELETE.

UPDATE table SET Column =REPLACE(column, '''', '')

|||

UPDATE TableName SET EMailAddrCol = REPLACE(EMailAddrCol, '''', '')

I hope this helps,

Best of Luck!

how organize a junction table?

Hi
I am importing XML documents with XML bulk load.
The tables look like this (kind of) with a junction table C connecting tableA and tableB.

tableA(nameID integer PRIMARY Key IDENTITY, name string)

tableB(placeID integer PRIMARY Key IDENTITY , placename string)

tableC(placeID integer FOREIGN Key, nameID integer FOREIGN key)

NameID and placeID have the property identity, and the xsd is mapped so that they are inserted in tableC as well as their parent table when they are generated.

My problem now is, how do I make sure that each placename or name only occur once with one ID? When trying to insert a placename that already exist in the database, I dont want to generate a new placeID for it. Instead, I would like to fetch the existing placeID and inserting it with the new nameID in tableC. It should be a quite common problem, since most many to many relationships would result in a junction table. As mentioned, I am loading the data with XML bulk load, I dont know if that would complicate matter..
All help will be greatly appreciated!
regards, Helenayou're right, it is a common problem

when using a surrogate key, such as an identity column, remember that each table must actually have a "real" primary key (called a candidate key in data modelling terminology)

all you have to do is declare a unique constraint on the real key, and the database will then prvent you from entering duplicates

rudy|||Thanks for your reply.

The Identity columns in tableA and tableB are also the "real" primary key. The "real" key in tableC would be a composite key made up by tableA and tableB's primary keys. Name in tableA and placename in tableB are declared unique. The composite key in tableC should also be unique, then the database will prevent duplicates values. But when trying to insert a new name but an old placename for example, how do I get the new nameID but the old placeID into tableC? It feels like I need to do a search to see if the placename exists, if no just insert data, if yes fetch placeID for that particular placename and insert. And this would be necessary whenever a junction table is involved.

/Helena|||perhaps you could do some research on the difference between surrogate and natural keys, but i assure you, even if you declare an identity column as a primary key, so that as far as the database is concerned it is the primary key, it isn't the "real" primary key, not from a modelling perspective, not in regard to duplicates

yes, make the composite key in tableC its primary key

as for what to do with potential duplicates, and how to find the original entry, so duplcates are not entered, and so that the tableC row links the correct parent rows, i'm sorry, i cannot help you, i've never written an XSD application

perhaps you could eliminate the dupes from the data before you attempt to load it with XML

rudy|||Ok, I see your point..

Eliminating the duplicates is unfortunately not an option.

Anyway, thanks for your help!sql

Friday, March 9, 2012

How is the Performance of the SQL with .Net?

Hi

I want to insert 1000s of records into SQL Server 2005 Database with some manipulation. So that i put into the For Loop and inserting record.

Inside the loop i am opening the connection and closing after use. The sample code is below

for(int i=0;i<1000;i++)
{

sqlCmd.CommandText = "ProcName";
sqlCmd.Connection = sqlCon;
sqlCmd.Connection.Open():
sqlCmd.ExecuteNonQuery();
sqlCmd.Connection.Close();

}

What my Question is.. How is the Performance of this Code..?? Will is take time to get the Connection and Close the Connection in every itration?

Or Shall I Open the Connection in Begining of the outside loop and close the connection at end of the Loop? will it increase the Performace?

Please clarify me these question.. Thanks in advance.

Hi,

Opening a connection and closing it takes a lot of extra resources, so use following.

1sqlCmd.CommandText ="ProcName";2sqlCmd.Connection = sqlCon;3sqlCmd.Connection.Open():45for(int i=0;i<1000;i++)6{7 sqlCmd.ExecuteNonQuery();8}910sqlCmd.Connection.Close();11

Wednesday, March 7, 2012

How is the 4 GB limit of SQL server express calculated

Hi
I wonder how the 4 GB limit is found.
Is it the size of the datafile only, or does the size also inlcude the
transaction log?
Regards
Kjell Arne Johansen
Kongsberg Maritime as
Hello,
The 4 GB database size limit applies only to data files and not to log (LDF)
files. However, there are no limits to the number of databases
that can be loaded/created to the SQL server instance.
Thanks
Hari
"Kjell Arne Johansen" <KjellArneJohansen@.discussions.microsoft.com> wrote in
message news:620B8D2E-5810-4C05-B168-595EAC94D712@.microsoft.com...
> Hi
> I wonder how the 4 GB limit is found.
> Is it the size of the datafile only, or does the size also inlcude the
> transaction log?
> Regards
> Kjell Arne Johansen
> Kongsberg Maritime as
|||Thank you for your answer.
"Hari Prasad" wrote:

> Hello,
> The 4 GB database size limit applies only to data files and not to log (LDF)
> files. However, there are no limits to the number of databases
> that can be loaded/created to the SQL server instance.
> Thanks
> Hari
> "Kjell Arne Johansen" <KjellArneJohansen@.discussions.microsoft.com> wrote in
> message news:620B8D2E-5810-4C05-B168-595EAC94D712@.microsoft.com...
>
>

How insert Arabic/urdu characters in SQL server

Hi

I am developing an application where i want to store the different language (i.e. chines,Arabic,urdu etc) character in database (SQL Server). so when i store arabic characters in SQL server , it stores the (???).

datatype of field is nvarchar.

is anybody know about the problem and solution.

Regards

Mubahsar Ghazi

The problem is called character conversion and you are getting it because you are using only NVarchar without doing column level collation for Arabic in your database. There are three collations for Arabic in SQL Server 2005. If you are using SQL Server 2000 you can still do column level collation, the links below deals with SQL Server 2005. Hope this helps.

144

binary.256

Binary

SQL_Latin1_General_1256_BIN

145

diction.256

Dictionary order, case-sensitive

SQL_Latin1_General_Cp1256_CS_AS_KI_WI

146

nocase.256

Dictionary order, case-insensitive

SQL_Latin1_General_Cp1256_CI_AS_KI_WI

http://msdn2.microsoft.com/en-us/library/ms144250(SQL.90).aspx

http://msdn2.microsoft.com/en-us/library/ms180175(SQL.90).aspx

|||

thanks for ur response

but i m still getting problems.....

i m pasting the whole code below.while executing it show the exceptionCast from string "?" to type 'Byte' is not valid.

.....................

Dim cAsString = HelpArea.Text ' HelpArea is text box where urdu/arabic characters can be writen

convertC = UniToVar(c) ' function written below

Cmd =

New SqlCommand("INSERT INTO tblCategoryDetail(FieldLang,FieldHelp)Values(' " & dpLanguage.SelectedItem.Text & " ', " & convertC(c) & ")", con)

lblMsg.Text = "Values have stored in database"

con.Open()

Cmd.ExecuteNonQuery()

CatchexAs Exception

lblMsg.Text = ex.Message

EndTry

con.Close()

Public

Function UniToVar(ByVal sTextAsString)AsObject

Try

Dim b()AsByte

b = Encoding.Unicode.GetBytes(sText)

Return b

Catch exAs Exception

lblMsg.Text = ex.Message

EndTry

EndFunction

|||

i have posted the whole function in previous message......and need the solution in very short time...... hoping early resopnse by ur side

regards

Mubashar Ghazi

|||

I want to query the database using SQL statements that contain Arabic letters... for example, this query won't return any results that start with the letter '?' even though if I try any english letters it works perfectly:

SELECT ArtistID, Name
FROM dbo.Artist
WHERE (Name LIKE '?' + '%')

I also tried switching:

SELECT ArtistID, Name
FROM dbo.Artist
WHERE (Name LIKE '%' + '?')

but it won't work.. any ideas ?

Thanks :)

|||

See if the posthttp://forums.asp.net/t/1167422.aspx can be helpful.

Friday, February 24, 2012

how i can make script Database with Data?

hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply|||Try www.sqlscripter.com to generate data scripts. It's free.
"Tark Siala" wrote:

> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise
+
> SP4.
> i have database contains Tables, and i want make script to build Tables on
> other Database,
> but i need this script include Data in Tables too, i can make that ? and
> how?
> thanks
> --
> Tarek M. Siala
>
>

how i can make script Database with Data?

hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply

how i can make script Database with Data?

hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply

Sunday, February 19, 2012

how i can connect to table in SQL?

hi
i working on VB6 + SQL2000
i have table called (tblBuffer)
and want do something in my application everytime table added new record
(its like trigger in SQL)
thats mean if someone add new record to this table, this table call my
application to do some event.
now i made small monitor (working every 15 second) to see if table have new
record to do something, but this idea need network and SQL Resources.
some one have best idea?
--
Best Regards
Tark M. Siala
Development Manager
INTERNATIONAL COMPUTER CENTER (ICC.Networking)
Mobile: +218-91-3125900
E-Mail: tarksiala@.icc-libya.com
Messenger: tarksiala@.hotmail.com
Web Page: http://www.icc-libya.com
Blog: http://spaces.msn.com/tarksiala
======================================In SQL Server 2005 I would recommend the dependency service but in SQL 2000
the only thing I can think of is a trigger that uses sp_OA... commands to
call a COM object you write in VB.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Tark Siala" <tarksiala@.icc-libya.com> wrote in message
news:O5QdxY8YGHA.4760@.TK2MSFTNGP03.phx.gbl...
> hi
> i working on VB6 + SQL2000
> i have table called (tblBuffer)
> and want do something in my application everytime table added new record
> (its like trigger in SQL)
> thats mean if someone add new record to this table, this table call my
> application to do some event.
> now i made small monitor (working every 15 second) to see if table have
> new record to do something, but this idea need network and SQL Resources.
> some one have best idea?
> --
> Best Regards
> Tark M. Siala
> Development Manager
> INTERNATIONAL COMPUTER CENTER (ICC.Networking)
> Mobile: +218-91-3125900
> E-Mail: tarksiala@.icc-libya.com
> Messenger: tarksiala@.hotmail.com
> Web Page: http://www.icc-libya.com
> Blog: http://spaces.msn.com/tarksiala
> ======================================
>