Suvendu's profileSuvendu's spacePhotosBlogListsMore Tools Help

Blog


    June 08

    Update Trigger

    Lets assume if you want to check whether any of the columns 2,3,4 or all the columns have been updated or not. Then use the following IF condition

    IF (COLUMNS_UPDATED() & 14) > 0

    14 is the bitmask for all three columns.

    for col 2, (this is col id you can see in syscolumns table) bitmask is power(2,(2-1))=2

    for col 3, bitmask is power(2,(3-1))=4

    for col 4, bitmask is power(2,(4-1))=8

    In above ex, since your checking all there columns bitmask is the sum of all. That comes to 14.
    June 07

    FreeSpace Alert in SQL Server 2000/2005

    Create a vbs file in C; Drive named as disk.vbs
    content are given below


    Set DiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3")
    for each Disk in DiskSet
    If (Disk.FreeSpace/Disk.Size) < 0.30 Then 
    WScript.Echo "Drive " + Disk.Name + " is low on space."
    End If
    Next
    

    Then Create a Job which will run on your requirement to check sapce and in Step 1 put the below code.

    create table ##diskspace (details varchar(1000))
    insert into ##diskspace
    exec xp_cmdshell 'cscript c:\disk.vbs'
    
    if (select count(*) from ##diskspace where cmd like '%low on space%') > 0
    begin
    declare @sql varchar(200)
    SELECT @sql ='select * from ##diskspace where  cmd like ''%low on space%'''
    PRINT @SQL
    exec master.dbo.xp_sendmail @recipients='Your ID', 
       @query = @sql,
       @subject = 'Disk Space Full'
    end
    drop table ##DiskSpace
    
    March 12

    Useful links for CSS

     

    I just started to create my CSS file for my project, and just want to check out if there are any recommended ways of doing this right. I just did a simple search in code project site, and found a lot of related articles which are useful. (Well, more to read now....)

    I'll add more to the list when I've found more information here.

    1. Internet Explorer & CSS issues

    2. Ten ways to speed up the download time of your web pages (some key points here, a must read article.)

    3.  Ten CSS tricks you may not know (There are some tricks here that you shouldn't miss too)

    4. CSS Help Pile - A huge pile of CSS-related tips, tricks & resources.

    5. 53 CSS-Techniques You Couldn't Live Without (Here, you can learn the specific technique that you want to use in your web site. Another Must Read article.)

    6. Layout Gala: a collection of 40 CSS layouts - Here you'll get some reference CSS layout sites.  

    7. MaxDesign - Sample CSS Page Layouts (with step by step layout tutorial too)

    8. CSSplay - There are some demos, menus, layouts, boxes examples.

    February 25

    Internet Explorer 8 soon available?

     

    The next release of IE will be called — wait for it — “Internet Explorer 8.”

    That’s it. More info to come — at least by Mix ‘08. Which is in March 2008. Sigh.

    See some Screenshots

    ie84

    ie8

    ie82

    ie83

    December 12

    bypass the Open/Save/Cancel dialog while file download

    If you want to bypass the Open/Save/Cancel dialog you just need to write below code

    Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name);

    Read and write to XML file from ASP C#

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Xml;
    using System.IO;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (!File.Exists("F:/Account.xml"))
            {

                XmlTextWriter textWritter = new XmlTextWriter("F:/Account.xml", null);
                textWritter.WriteStartDocument();
                textWritter.WriteStartElement("USERS");
                textWritter.WriteEndElement();

                textWritter.Close();
            }

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load("F:/Account.xml");

            XmlElement subRoot = xmlDoc.CreateElement("User");
            //UserName
            XmlElement appendedElementUsername = xmlDoc.CreateElement("UserName");
            XmlText xmlTextUserName = xmlDoc.CreateTextNode(txtUsrName.Text.Trim());
            appendedElementUsername.AppendChild(xmlTextUserName);
            subRoot.AppendChild(appendedElementUsername);
            xmlDoc.DocumentElement.AppendChild(subRoot);
            //Email

            XmlElement appendedElementEmail = xmlDoc.CreateElement("Email");
            XmlText xmlTextEmail = xmlDoc.CreateTextNode(txtEmail.Text.Trim());
            appendedElementEmail.AppendChild(xmlTextEmail);
            subRoot.AppendChild(appendedElementEmail);
            xmlDoc.DocumentElement.AppendChild(subRoot);

            xmlDoc.Save("F:/Account.xml");
        }
        public void  ReadXML(string UrlToXmlFile)
        {
            FileStream fs = new FileStream(UrlToXmlFile,FileMode.Open,FileAccess.Read,
                                   FileShare.ReadWrite);
            XmlDocument xmldoc = new XmlDocument();
           xmldoc.Load(fs);
         //  DisplayCatalog();
                XmlNodeList xmlnode = xmldoc.GetElementsByTagName("User");
                Response.Write("Here is the list of Users\n\n");

           for (int i = 0; i < xmlnode.Count; i++)
           {
             //  XmlAttributeCollection xmlattrc = xmlnode[i];
               XmlAttributeCollection xmlattrc = xmlnode[i].Attributes;
               Response.Write(xmlnode[i].FirstChild.Name);
               Response.Write(":\t" + xmlnode[i].FirstChild.InnerText);

               //Last Child of the XML file - Catalog.xml - returned
               //Example: <Publisher>Sams</Publisher>

               Response.Write(xmlnode[i].LastChild.Name);
               Response.Write(":\t" + xmlnode[i].LastChild.InnerText);
              // Response.Write();
            }

        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            ReadXML("F:/Account.xml");
        }
    }

    October 24

    Create Simple Job with Query Analyser(every day 5 min duration schedule)

    USE msdb
    EXEC sp_add_job @job_name = 'AdminApprove', @enabled = 1
    go
    EXEC sp_add_jobstep @job_name = 'AdminApprove',  @step_name = 'Set AdminApprove',
    @subsystem = 'TSQL',
    @command = 'EXEC sp_approve_dziuk'
    go
    EXEC sp_add_jobschedule @job_name = 'AdminApprove', @name =
    'Schedule AdminApprove',
    @freq_type = 4, @freq_interval = 1, @active_start_date = 20071007,
    @freq_subday_type = 4, @freq_subday_interval = 5
    go

    October 13

    Disable DatagridView Column Sorting in C#

    dataGridView1.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable;

    October 04

    NEWID vs NEWSEQUENTIALID

     


    1. NewSequentialID() and NewID() both generates the GUID of datatype of uniqueidentifier.
    2. NewID() generates the GUID in random order
    3. NewSequentialID() generates the GUID in sequential order.
    4. NewSequentialID() can be used ONLY in default clause of a table.
    5. NewSequentialID() is easily predictable
    6. So if security is a major concern then go for NewID() instead of NewSequentialID().

    Fun With SQL Server

    Set nocount on
    Declare @TblLayout table([ID] int Identity, Canvas Char(75))

    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)
    Insert into @TblLayout Select Replicate (Convert(Varchar, 0x7E), 75)

    --- Vz employees House ...
    Update @TblLayout Set Canvas = Stuff(Canvas, 42, 24 , Convert(Varchar, 0x7C5F5F5F5F5F5F5F5F5F5F5F5F5F5F7C5F5F5F5F5F7C))Where ID = 5

    Update @TblLayout Set Canvas = Stuff(Canvas, 42, 24 , Convert(Varchar, 0x7C2020205B20205D20205B20205D207C20202020207C)) Where ID = 4

    Update @TblLayout Set Canvas = Stuff(Canvas, 42, 24 , Convert(Varchar, 0x2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F5C5C5C5C5C5C)) Where ID = 3

    Update @TblLayout Set Canvas = Stuff(Canvas, 43, 23 , Convert(Varchar, 0x2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F2F5C5C5C5C)) Where ID = 2

    Update @TblLayout Set Canvas = Stuff(Canvas, 44, 21, Convert(Varchar, 0x5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F)) Where ID = 1

    -- Picture of a Guy ...
    Update @TblLayout Set Canvas = Stuff(Canvas, 10,10, Convert(Varchar, 0x285F5F5F5B5F5F5F29)) Where ID = 27

    Update @TblLayout Set Canvas = Stuff(Canvas, 11,8, Convert(Varchar, 0x7C5F5F7C5F5F7C)) Where ID = 26

    Update @TblLayout Set Canvas = Stuff(Canvas, 11,8, Convert(Varchar, 0x7C20207C20207C)) Where ID = 25

    Update @TblLayout Set Canvas = Stuff(Canvas, 11,8, Convert(Varchar, 0x7C20207C20207C)) Where ID = 24

    Update @TblLayout Set Canvas = Stuff(Canvas, 10,9, Convert(Varchar, 0x5C7C5F5F5F5F2F202F)) Where ID = 23

    Update @TblLayout Set Canvas = Stuff(Canvas, 9,11, Convert(Varchar, 0x5C207C20416553202F202F)) Where ID = 22

    Update @TblLayout Set Canvas = Stuff(Canvas, 9,11, Convert(Varchar, 0x2F5F2F20415453205C5F5C)) Where ID = 21

    Update @TblLayout Set Canvas = Stuff(Canvas, 10,9, Convert(Varchar, 0x2F202060606020205C)) Where ID = 20

    Update @TblLayout Set Canvas = Stuff(Canvas, 11,7, Convert(Varchar, 0x5F5C5F755F2F5F)) Where ID = 19

    Update @TblLayout Set Canvas = Stuff(Canvas, 11,7, Convert(Varchar, 0x5C20302030202F)) Where ID = 18

    Update @TblLayout Set Canvas = Stuff(Canvas, 11,7, Convert(Varchar, 0x2F2F2F2F2F2F2F)) Where ID = 17

    --Time to travel
    Update @TblLayout Set Canvas = Stuff(Canvas, 11,3, Convert(Varchar, 0x282029)) Where ID = 6

    Update @TblLayout Set Canvas = Stuff(Canvas, 10,3, Convert(Varchar, 0x282029)) Where ID = 7

    Update @TblLayout Set Canvas = Stuff(Canvas, 7,27, Convert(Varchar, 0x5F5F2F202F5F5F5F5F5F20202020205F5F5F5F5F5F5F5F5F)) Where ID = 8

    Update @TblLayout Set Canvas = Stuff(Canvas, 5,27, Convert(Varchar, 0x287C202020202020202020207C2020207C2020202020202020207C)) Where ID = 9

    Update @TblLayout Set Canvas = Stuff(Canvas, 6,26, Convert(Varchar, 0x7C205B5D205B5D205B5D207C292D287C205B5D205B5D205B5D7C)) Where ID = 10

    Update @TblLayout Set Canvas = Stuff(Canvas, 6,27, Convert(Varchar,
    0x7C5F5F5F5F5F5F5F5F5F5F7C2020207C5F5F5F5F5F5F5F5F5F7C)) Where ID = 11

    Update @TblLayout Set Canvas = Stuff(Canvas, 7,24, Convert(Varchar, 0x303030303030303030302020202020303030303030303030)) Where ID = 12

    Select Canvas [ ] FROM @TblLayout

    October 03

    Enable/Disable Trigger

     

    --DISABLE TRIGGER--------

    ALTER TABLE Table_Name
    DISABLE TRIGGER Trigger_Name

    --ENABLE TRIGGER--------

    ALTER TABLE Table_Name
    ENABLE TRIGGER Trigger_Name

     

    --Geting Status of Trigger

    SELECT
             name,
             status = CASE WHEN OBJECTPROPERTY (id, 'ExecIsTriggerDisabled') = 0
                THEN 'Enabled' ELSE 'Disabled' END,
             owner = OBJECT_NAME (parent_obj)
          FROM
             sysobjects
    WHERE
             type = 'TR'

    September 28

    Export DatagridView to MSExcel with out using COM object from C# 2005

    public static void exportToExcel(DataTable source, string fileName)
           {

               System.IO.StreamWriter excelDoc;

               excelDoc = new System.IO.StreamWriter(fileName);
               const string startExcelXML = "<xml version>\r\n<Workbook " +
                     "xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n" +
                     " xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n " +
                     "xmlns:x=\"urn:schemas-    microsoft-com:office:" +
                     "excel\"\r\n xmlns:ss=\"urn:schemas-microsoft-com:" +
                     "office:spreadsheet\">\r\n <Styles>\r\n " +
                     "<Style ss:ID=\"Default\" ss:Name=\"Normal\">\r\n " +
                     "<Alignment ss:Vertical=\"Bottom\"/>\r\n <Borders/>" +
                     "\r\n <Font/>\r\n <Interior/>\r\n <NumberFormat/>" +
                     "\r\n <Protection/>\r\n </Style>\r\n " +
                     "<Style ss:ID=\"BoldColumn\">\r\n <Font " +
                     "x:Family=\"Swiss\" ss:Bold=\"1\"/>\r\n </Style>\r\n " +
                     "<Style     ss:ID=\"StringLiteral\">\r\n <NumberFormat" +
                     " ss:Format=\"@\"/>\r\n </Style>\r\n <Style " +
                     "ss:ID=\"Decimal\">\r\n <NumberFormat " +
                     "ss:Format=\"0.0000\"/>\r\n </Style>\r\n " +
                     "<Style ss:ID=\"Integer\">\r\n <NumberFormat " +
                     "ss:Format=\"0\"/>\r\n </Style>\r\n <Style " +
                     "ss:ID=\"DateLiteral\">\r\n <NumberFormat " +
                     "ss:Format=\"mm/dd/yyyy;@\"/>\r\n </Style>\r\n " +
                     "</Styles>\r\n ";
               const string endExcelXML = "</Workbook>";

               int rowCount = 0;
               int sheetCount = 1;
               /*
              <xml version>
              <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
              xmlns:o="urn:schemas-microsoft-com:office:office"
              xmlns:x="urn:schemas-microsoft-com:office:excel"
              xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
              <Styles>
              <Style ss:ID="Default" ss:Name="Normal">
                <Alignment ss:Vertical="Bottom"/>
                <Borders/>
                <Font/>
                <Interior/>
                <NumberFormat/>
                <Protection/>
              </Style>
              <Style ss:ID="BoldColumn">
                <Font x:Family="Swiss" ss:Bold="1"/>
              </Style>
              <Style ss:ID="StringLiteral">
                <NumberFormat ss:Format="@"/>
              </Style>
              <Style ss:ID="Decimal">
                <NumberFormat ss:Format="0.0000"/>
              </Style>
              <Style ss:ID="Integer">
                <NumberFormat ss:Format="0"/>
              </Style>
              <Style ss:ID="DateLiteral">
                <NumberFormat ss:Format="mm/dd/yyyy;@"/>
              </Style>
              </Styles>
              <Worksheet ss:Name="Sheet1">
              </Worksheet>
              </Workbook>
              */
               excelDoc.Write(startExcelXML);
               excelDoc.Write("<Worksheet ss:Name=\"Sheet" + sheetCount + "\">");
               excelDoc.Write("<Table>");
               excelDoc.Write("<Row>");
               for (int x = 0; x < source.Columns.Count; x++)
               {
                   excelDoc.Write("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
                   excelDoc.Write(source.Columns[x].ColumnName);
                   excelDoc.Write("</Data></Cell>");
               }
               excelDoc.Write("</Row>");
               foreach (DataRow x in source.Rows)
               {
                   rowCount++;
                   //if the number of rows is > 64000 create a new page to continue output
                   if (rowCount == 64000)
                   {
                       rowCount = 0;
                       sheetCount++;
                       excelDoc.Write("</Table>");
                       excelDoc.Write(" </Worksheet>");
                       excelDoc.Write("<Worksheet ss:Name=\"Sheet" + sheetCount + "\">");
                       excelDoc.Write("<Table>");
                   }
                   excelDoc.Write("<Row>"); //ID=" + rowCount + "
                   for (int y = 0; y < source.Columns.Count; y++)
                   {
                       System.Type rowType;
                       rowType = x[y].GetType();
                       switch (rowType.ToString())
                       {
                           case "System.String":
                               string XMLstring = x[y].ToString();
                               XMLstring = XMLstring.Trim();
                               XMLstring = XMLstring.Replace("&", "&");
                               XMLstring = XMLstring.Replace(">", ">");
                               XMLstring = XMLstring.Replace("<", "<");
                               excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" +
                                              "<Data ss:Type=\"String\">");
                               excelDoc.Write(XMLstring);
                               excelDoc.Write("</Data></Cell>");
                               break;
                           case "System.DateTime":
                               //Excel has a specific Date Format of YYYY-MM-DD followed by 
                               //the letter 'T' then hh:mm:sss.lll Example 2005-01-31T24:01:21.000
                               //The Following Code puts the date stored in XMLDate
                               //to the format above
                               DateTime XMLDate = (DateTime)x[y];
                               string XMLDatetoString = ""; //Excel Converted Date
                               XMLDatetoString = XMLDate.Year.ToString() +
                                    "-" +
                                    (XMLDate.Month < 10 ? "0" +
                                    XMLDate.Month.ToString() : XMLDate.Month.ToString()) +
                                    "-" +
                                    (XMLDate.Day < 10 ? "0" +
                                    XMLDate.Day.ToString() : XMLDate.Day.ToString()) +
                                    "T" +
                                    (XMLDate.Hour < 10 ? "0" +
                                    XMLDate.Hour.ToString() : XMLDate.Hour.ToString()) +
                                    ":" +
                                    (XMLDate.Minute < 10 ? "0" +
                                    XMLDate.Minute.ToString() : XMLDate.Minute.ToString()) +
                                    ":" +
                                    (XMLDate.Second < 10 ? "0" +
                                    XMLDate.Second.ToString() : XMLDate.Second.ToString()) +
                                    ".000";
                               excelDoc.Write("<Cell ss:StyleID=\"DateLiteral\">" +
                                            "<Data ss:Type=\"DateTime\">");
                               excelDoc.Write(XMLDatetoString);
                               excelDoc.Write("</Data></Cell>");
                               break;
                           case "System.Boolean":
                               excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" +
                                           "<Data ss:Type=\"String\">");
                               excelDoc.Write(x[y].ToString());
                               excelDoc.Write("</Data></Cell>");
                               break;
                           case "System.Int16":
                           case "System.Int32":
                           case "System.Int64":
                           case "System.Byte":
                               excelDoc.Write("<Cell ss:StyleID=\"Integer\">" +
                                       "<Data ss:Type=\"Number\">");
                               excelDoc.Write(x[y].ToString());
                               excelDoc.Write("</Data></Cell>");
                               break;
                           case "System.Decimal":
                           case "System.Double":
                               excelDoc.Write("<Cell ss:StyleID=\"Decimal\">" +
                                     "<Data ss:Type=\"Number\">");
                               excelDoc.Write(x[y].ToString());
                               excelDoc.Write("</Data></Cell>");
                               break;
                           case "System.DBNull":
                               excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" +
                                     "<Data ss:Type=\"String\">");
                               excelDoc.Write("");
                               excelDoc.Write("</Data></Cell>");
                               break;
                           default:
                               throw (new Exception(rowType.ToString() + " not handled."));
                       }
                   }
                   excelDoc.Write("</Row>");
               }
               excelDoc.Write("</Table>");
               excelDoc.Write(" </Worksheet>");
               excelDoc.Write(endExcelXML);
               excelDoc.Close();
           }

    Left Right and MID function in C#

    public static string Left(string param, int length)
            {
                //we start at 0 since we want to get the characters starting from the
                //left and with the specified lenght and assign it to a variable
                string result = param.Substring(0, length);
                //return the result of the operation
                return result;
            }
            public static string Right(string param, int length)
            {
                //start at the index based on the lenght of the sting minus
                //the specified lenght and assign it a variable
                string result = param.Substring(param.Length - length, length);
                //return the result of the operation
                return result;
            }

            public static string Mid(string param, int startIndex, int length)
            {
                //start at the specified index in the string ang get N number of
                //characters depending on the lenght and assign it to a variable
                string result = param.Substring(startIndex, length);
                //return the result of the operation
                return result;
            }

            public static string Mid(string param, int startIndex)
            {
                //start at the specified index and return all characters after it
                //and assign it to a variable
                string result = param.Substring(startIndex);
                //return the result of the operation
                return result;
            }

    September 25

    Get Ascii number from Character using c#

    public Int32 FindAsciiCode( string str)
            {
                char myChar = str[0];
                byte myByte = (byte)myChar;
                char myOtherChar = (char)myByte;
                return myByte;
            }

    September 22

    SQLite OPENSource

    SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine.

    SQLite is an approriate database engine to use versus situations where a client/server database engine might be a better choice.

    Zero-Configuration

    SQLite does not need to be "installed" before it is used. There is no "setup" procedure. There is no server process that needs to be started, stopped, or configured. There is no need for an administrator to create a new database instance or assign access permissions to users. SQLite uses no configuration files. Nothing needs to be done to tell the system that SQLite is running. No actions are required to recover after a system crash or power failure. There is nothing to troubleshoot.

    SQLite just works.

    Other more familiar database engines run great once you get them going. But doing the initial installation and configuration can be intimidatingly complex.

    • Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures.
    • Zero-configuration - no setup or administration needed.
    • Implements most of SQL92. (Features not supported)
    • A complete database is stored in a single disk file.
    • Database files can be freely shared between machines with different byte orders.
    • Supports terabyte-sized databases and gigabyte-sized strings and blobs. (See limits.html.)
    • Small code footprint: less than 250KiB fully configured or less than 150KiB with optional features omitted.
    • Faster than popular client/server database engines for most common operations.
    • Simple, easy to use API.
    • TCL bindings included. Bindings for many other languages available separately.
    • Well-commented source code with over 98% test coverage.
    • Available as a single ANSI-C source-code file that you can easily drop into another project.
    • Self-contained: no external dependencies.
    • Sources are in the public domain. Use for any purpose.

    SQL Server

    How to pass a variable to a linked server query

     

    When you query a linked server, you frequently perform a pass-through query that uses the OPENQUERY, OPENROWSET, or OPENDATASOURCE statement. You can view the examples in SQL Server Books Online to see how to do this by using pre-defined Transact-SQL strings, but there are no examples of how to pass a variable to these functions. This article provides three examples of how to pass a variable to a linked server query.
    To pass a variable to one of the pass-through functions, you must build a dynamic query.

     DECLARE @TSQL varchar(8000), @VAR char(2)
          SELECT  @VAR = 'CA'
          SELECT  @TSQL = 'SELECT * FROM OPENQUERY(MyLinkedServer,''SELECT * FROM pubs.dbo.authors WHERE state = ''''' + @VAR + ''''''')'
          EXEC (@TSQL)
    Pass the Whole Query
    When you have to pass in the whole Transact-SQL query or the name of the linked server (or both), use code that is similar to the following sample:
    DECLARE @OPENQUERY nvarchar(4000), @TSQL nvarchar(4000), @LinkedServer nvarchar(4000)
    SET @LinkedServer = 'MyLinkedServer'
    SET @OPENQUERY = 'SELECT * FROM OPENQUERY('+ @LinkedServer + ','''
    SET @TSQL = 'SELECT au_lname, au_id FROM pubs..authors'')' 
    EXEC (@OPENQUERY+@TSQL)