Menu Links

Tuesday, August 23, 2011

Get the table data in the csv format file

select top 10 'exec master..xp_cmdshell'+ ' '''+ 'bcp'
+ ' ' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + ' out'+ ' c:\Temp\'
+ TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.csv' + ' -c -t; -T -S' + @@servername+ ''''from INFORMATION_SCHEMA.TABLESwhere TABLE_TYPE = 'BASE TABLE'

How to store HTML code in database in ASP.NET application?

// For encode the data into the data base
// Server.Encode() will help to convert entire HTML to encoded format.

protected void btnSubmit_Click(object sender, EventArgs e)
    {
int status = objBL.SaveContent(Server.HtmlEncode(wftxtContent.Text),wddlPageName.SelectedValue.ToString());
    }

public int SaveContent(string content,string pageid)
        {

Query = "UPDATE [PageContent] SET PageContent = '" + content + "' WHERE [ID] = " + pageid;

            Database objDB = DatabaseFactory.CreateDatabase();
           
            int chkInsert = objDB.ExecuteNonQuery(CommandType.Text, Query);
           
            return chkInsert;

        }
// For decode the data from data base
// Server.Encode() will help to convert entire HTML to encoded format.


wftxtContent.Text = Server.HtmlDecode(objBL.getContent());

public string getContent(string pageid)
        {
           
Query = "SELECT PageContent FROM [PageContent] WHERE [ID] = " + pageid;

            Database objDB = DatabaseFactory.CreateDatabase();
string Content = objDB.ExecuteScalar(CommandType.Text, Query).ToString();

            return Content;

        }

Monday, August 22, 2011

What is SQL Server Import / Export wizard for SSIS?

It helps to DBA and developer to data movement from a source to any targeted source.
Steps to run a wizard in SQL Server
1.       Select a database in Microsoft SQL Server Management Studio.
2.       Right click on database, Go to Tasks and select Import / Export wizard.
3.        New window will appear

4.       Click Next; it will take to another page for the source selection


















5.       Select the data source; by default it is SQL Native client if your source is different your can chose data source as access, excel, txt file or any other database provider.
6.       If you have selected the data source SQL Native client then need to provide the server and credential details and chose database from where your want to transfer data.

7.       If you have selected any other data source like access, excel or txt file then browser the file from the physical path. And here you need to follow some more steps I will explain in my next post.
8.       Click next; It will take to another page for the destination selection. This section is as same as the data source.
9.       Click next ; It will take to summary page
10.   Click finish