Showing posts with label sqlserver. Show all posts
Showing posts with label sqlserver. Show all posts

Friday, March 30, 2012

How to schedule full population of a catalog

Hello all,

Could some kind soul tell me how to schedule a "full population" of a FullText catalog in SQLServer 2005?

The fulltext catalog was created correctly and named "CBizOneCatalog". I want to schedule the full population to run daily at 2am.

I'm no expert, more of a wizard guy, but I can get around the Managment Studio.

Ray

Hi Ray,

Do you not see the Full Text Catalog Schedule in wizard?

Regards,

sql

Wednesday, March 7, 2012

how to retrieve random values from a database table

how to retrieve randomly rows from a sqlserver database tableHi,

Use TABLESAMPLE

Example.

SELECT FirstName, LastName
FROM Person.Contact
TABLESAMPLE (10 PERCENT) ;

OR

SELECT FirstName, LastName
FROM Person.Contact
TABLESAMPLE (10 ROWS) ;

Friday, February 24, 2012

How to retreive data from Excel to SQL SERVER Database table

Hi Friends,

I am Using SQL SERVER 2005

I need to retreive data from Excel file to SQLSERVER table..

Thanks in advance

Regards

Rajkumar.M

There are many ways to do this. You may use SQL Server integration services, or you may create a persistent connection to any data source supporting OLE DB (including MS Excel) via linked servers, or you may use OPENDATASOURCE clause in your query.

http://support.microsoft.com/kb/321686 will help you start.

How to retreive data from Excel into SQLSERVER database table

Hi friends,

I need to retreive data from Excel into SQLSERVER database table

give me reply asap.

Thanks in advance...

you can do it, using SqlBulkCopy using ADO.NET

I have developed a small tool in C# that can work for you,

I have tested it using sql server 2000/2005 and works ok
but you require Framework 2.0

so if you wanna test it, just mail me
vish4forum at yahoo dot com. I will send you that exe

|||

Hi Vish,

I found ur reply useful..

please send me sample code that will be better

|||

Hi Vish,

I tried using SQLBulk copy..But i got error 'could not find installable ISAM'

Here is my code

string excelConnectionString = @."Provider=Microsoft.Jet.OLEDB.4.0;Data Source=192.168.0.25;Extended
Properties=""Excel 11.0;HDR=YES;IMEX=1;""";

OleDbConnection con = new OleDbConnection(excelConnectionString);


con.Open();
OleDbCommand cmd = new OleDbCommand("select * from [test$]", con);
dr = cmd.ExecuteReader();

SqlConnection con1 = new SqlConnection();
con1.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["strcon"];
con1.Open();
SqlBulkCopy bulk1 = new SqlBulkCopy(con1);
bulk1.DestinationTableName = "tblexcel";
bulk1.WriteToServer(dr);
Response.Write("Loaded");

|||

Checkout this two articles

1)http://davidhayden.com/blog/dave/archive/2006/05/31/2976.aspx

2)http://support.microsoft.com/kb/321686

hope this helps !!!

How to Retain Text and Paragraph Formatting

Is it possible to retain text or paragraph formatting in a SqlServer 2005 Express edition table? If so, how?

I am particularly interested in keeping a linebreak between paragraphs and the only way I can think to do that is to put each paragraph in its own row. But I want some input before I undertake that substantial task.

Thanks for any help provided.
You can use char(10) which is the hard break in SQL.

eg.

Code Snippet

Print 'Microsoft' + char(10) + 'Website'

The Output is like below:
Microsoft
Website

You can as many as char(10) to provide line break in your query.

Even the below syntax will also work.

Code Snippet

select 'Microsoft' + char(10) + 'Website'

|||Hi Vidhya. Thanks for your advice.

I am trying to understand how to insert the data into a table and retrieve to a control on a VB form. In Visual Basic Express I tried including the char(10) with the data by pasting it into my table like this:

Paragraph 1 text here. + char(10) + Paragraph 2 text here. + char(10) + Paragraph 3 text here.

But all I get for output in my datagrid control is the literal string as one block of text.

I use a similar technique with html tags (

) if I am outputing to a webcontrol and it seems to work okay if the control renders html (ie.,

Paragraph 1 text here

Paragraph 2 text here

Paragraph 3 text here

). But this doesn't work for Windows forms unless I am using a webbrowser control and html controls (which I don't want to do).

So I opened up SQL Server Management Studio Express and created a database with a table (text) and column (paragraph) and ran these scripts:

INSERT INTO Text (Paragraph)
VALUES ('Paragraph 1 text here.' + char(10) + 'Paragraph 2 text here.' + char(10) + 'Paragraph 3 text here.')

SELECT *
FROM Text

select 'Microsoft' + char(10) + 'Website'
From Text

But my output is still a single line of text without paragraph formatting.

When I run the code you provided (Print 'Microsoft' + char(10) + 'Website'), that works perfectly. But I don't know how to insert and retrieve the formatted text data in my db.

I am relatively new to SQL, so I realize that I am missing something simple in my implementation of your advice. Any suggestions on how to apply this concept is greatly appreciated.|||To Insert into table jus insert as usual

insert into <tablename> values('col1','col2')


To select from the table with char(10) you can use

select col1,char(10),col2 from <tablename>

Run the above query in text format(ctrl+t)

|||Thanks for the follow-up. I have had some success (I think). Here is what I have tried:

CREATE TABLE Paragraph
(ID int Primary Key IDENTITY(1,1) NOT NULL,
FormattedText nvarchar(500) NOT NULL)

INSERT INTO Paragraph (FormattedText)
VALUES ('Paragraph 1 text here.' + char(10) + 'Paragraph 2 text here.' + char(10) + 'Paragraph 3 text here.')

select FormattedText from Paragraph

If I have the "Results to Text" button clicked, the output looks great, like this:

Paragraph 1 text here.
Paragraph 2 text here.
Paragraph 3 text here.

If I output with "Results to Grid" clicked, it loses the format and looks like this:

Paragraph 1 text here. Paragraph 2 text here. Paragraph 3 text here.

So I think I am making progress. I am getting the data into my table ok. Getting it out in the proper paragraph format is the challenge, which is easy in Management Studio.

But when I use the same table in Visual Basic and output the row of data to a datagrid, it comes out like this, without the paragraph formatting:

Paragraph 1 text here. Paragraph 2 text here. Paragraph 3 text here.

So my problem now is how to get it to display properly on my Windows Form. Any thoughts on this, or do I need to switch to the VB forum?|||Im not sure abt VB. But i think there is a command "Break" in VB. Pls check
|||I will look into it further. There is a break property for creating menus, but I am not sure if it can be applied to datagrids or other controls for displaying formatted data.

Thanks again for your helpl.

Sunday, February 19, 2012

how to restore the sqlserver2000s mdb files to another sqlserver

Hi there,
My sqlserver 2000 was down(means failed to reload ) I just copied all the mdb files and log files from that server. now i wants to reload my databases from the mdb files. is it possible?. If so pls inform me how to do that.
Its very urgent. Pls help me:
confused:If you have all of the MDF and LDF files look into using SP_ATTACH_DB. After that you'll need to recreate the logins in MASTER from those in your databases.

How to restore the entire replication topology in different boxe

We are migrating the entire sqlserver environment from Window2000 to Windows
2003 on different boxes with different NT servernames. I have installed the
sqlserver instances and I have restored the publisher, distribution db on the
primary side and the subscriber db on the replicated side. However, I don't
see any publications under the replication folder. Do I need to go through
the replication configuration first then restore the distribution?
Please advise. Thanks.
Wen,
for migrating to another server which has a different netbios name, the only
realistic solution is to script out the publications on the original setup,
install the new servers and then run the scripts on the new server, changing
the necessary parts eg servername and job owners.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)