.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Square brackets and Curly brackets

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :Sql Server
Hi I'm just learning about joins. Anyway I've found this example in a book which has square brackets around the name of a table used. I don't think the name of the table is a reserved word. Does anyone know why the square brackets were used? :- SELECT Customers.CustomerID, Customers.CompanyName      Orders.OrderID, Orders.Orderdate      FROM (Customers      INNER JOIN Orders      ON Customers.CustomerID = Orders.CustomerID)      INNER JOIN [Orders Details]      ON Orders.OrderID = [Order Details].OrderID I think I've just worked it out that the square bracked are needed because there is a space character in the table name. But while we're on the subject would anyone be able to tell me how to work out where the best place is to put the enclosing brackets. For example, if another JOIN was to be used how would you know where to put the brackets so that he code looks as neat as possible. Kind Regards jmatty2000 p.s. The book example is from a book called MS SQL Server 2005 Express in 24 Hours by Alison Balter. 

View Complete Post

More Related Resource Links

Why are square brackets needed for column names

Hi I'm just trying to get used to using Joins if anyone can please tell me why this only works if I put the column name in square brackets. I only managed to work this out because after struggling I had look at how it should look when designing a New View. This works :- SELECT FoodInv.Calories FROM (FoodInv INNER JOIN Diary ON Diary.FoodIndex = FoodInv.[Index]) WHERE Diary.Date = '2010-09-05' but this didn't if I leave out the square brackets :- SELECT FoodInv.Calories FROM (FoodInv INNER JOIN Diary ON Diary.FoodIndex = FoodInv.Index) WHERE Diary.Date = '2010-09-05' Without the brackets would generate error within the Messages window :- Msg 1018, Level 15, State 1, Line 7 Incorrect syntax near 'Index'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax. Any hints are welcome. Thank you. Matthew

Nesting serialized classes with XmlSerializer without escaped brackets

Hi The company I work for use a state implementation based on the XmlSerializer generic class in so far that we have state classes with simple public variables and no logic which we then use the XMLSerializer to serialize in in great extend nest. For instance class A has a Class B and a class C variable, each with a state class being serialized and put into a state class of the owner class. Is there any way outside actually implementing IXmlSerializable that I can allow to include XML directly in own output xml instead of escaping it when it meets brackets in strings for instance? The deal is that since all state classes individually are serialized simple classes, I know that they contain valid XML and that that will conform to the XMLDOM even if piecing them together and manually implementing the serializers will be quite time consuming even if limiting to the CSharp framework, but the multi layer escaped structure is awfull to the eye. See this simplified example: using System.Xml; using System.Xml.Serialization; using System; using System.IO; namespace TingTester { class Program { static void Main(string[] args) { var simpleser = new XmlSerializer(typeof(LittleStateClass)); string serialized = Serialize(GetSimpleVersion(), simpleser); Console.WriteLine("Simple elements contain no escapes: {0}", !serialized.Contains("&"

[] brackets before a class or method Declaration

Hi Guys,Some times we have [] brackets before a class or method Declaration.  Can anyone guide me please in understanding those squre brackets.  what do we write in those and what they represent. like this [SerializableAttribute][ObsoleteAttribute]class Moon { }Thanks in advance.

How do I match and not capture something in brackets in the middle of a string that I am capturing?


This is my input string:

, a. [the Cat.] Pertaining to the Cat.


This is my regular expression:


(?!^|,) means match the beginning of the string or a comma, negative lookahead

([\s,\S]*?) means match anything

[A-Z] means match a capital letter-- in this case, it was meant to capture 'P' from "Pertaining to..."


This is what I catch:

a. [the


This is what I want to catch:



Some input strings, like the one above, have [some text in brackets] while some input strings do NOT.

If there is bracketed text in the string with a capital letter,

1) how do I prevent the capital letter in the brackets from matching the [A-Z], and

2) how do I not capture the bracketed text?


Thanks for the help!

Delete nested brackets


My second question, I'm trying to Delete brackets that begin with [[image......]], however there can be [[word...]] within the brackets.  Does anyone know how to delete these, once again I'm using php and was planning on using preg_replace.


[[Image:Brent Spot monthly.svg|thumb|400px|[[Brent Crude|Brent]] barrel petroleum [[spot price]]s, May 1987 – Jan 2011. Due to exchange rate fluctuations, the real price line is only relevant to the United States and countries with a currency tied to the U.S. dollar at a constant rate throughout the period.]] text blah blah blah...

Would change to

text blah blah blah...



brackets around object names


I am doing something that requires me to build a dynamic sql statement as I loop through certain user tables in sys.objects. The issue I am running into is that some tables have reserved words or special characters or whatever else that requires me to wrap that table name around square brackets. Now, I know I can build the square brackets around the table name when I build my dynamic sql, but I thought I remember reading somewhere there is another way to do this using some function or something.

In other words, is there another way to get this result set without typing '[' and ']'?

select top 10 '[' + name + ']' from sys.objects where type = 'U'


The reason why I ask is because in that article that I think I remember reading, there was a reason why you shouldn't do it this way. But, I could be totally off in my memory.


How do I restyle a textbox to have square corners?

Hi, I hope I haven't missed something simple, but I can't find a way to give a basic text box square instead of rounded corners. I tried writing a basic control template, and the control more or less looks correct, but it doesn't work as a text box anymore. Obviously I'm missing something here. Am I on the right track, or is there a simpler way to get square corners?   Nathanael

Square on page



I would like to have a square on my asp page where I want to put my content in. So for example and to put in into words to be very clear:

- one line 10 px from top

- one line 10 px from left

- one line 10 px from right

- one line 10 px from bottom.

And when I resize my window, it should always be the same square. Also when my content grows, my left and right line should grow bigger and my bottom line should go down.

Any idea how to do this? I would like to do it with asp and css...

Many thanks.

can't resize thumbnail to be square



On our website we have images displayed on each of our product pages.

Our products are added via a backend user interface, where admin can add product name, details, sizes and a product image via upload .

 The image thumbnails are automatically resized to be 123 x 123 px, on our front page, and product pages.

 The problem is when the image is not an exact square to begin with,  say 700  wide x 500 high. ( a rectangle)

If I resize it to 123 x123 the image would be completely disproportionate , if I resampled to a 123 width that would give a height of 88px, and a lot of white space on the image height to make up the box on my thumbnail

You can get a better idea by actually taking a look at my site, here's a specific page where this comes up


 or here's a screen shot of the problem

square thumbnail

Obviously the image itself looks nice on the product page, but it's the thumbnail I would like to fix.

center a portrait or landscape image in a square


I'm horrible at math, or the formula simply eludes me.I need to replace a program I bought years ago that resized my photos, so I'm starting from scratch with this, that mimicks the program I was using.

I'm just trying to center a landscape or portrait image in a square, but coming up with the correct X or Y against the canvas size is throwing me off. I'll sleep on it for tonight and try again tommorrow. The image quality is fine.

Here's what I have, any code modifications would be appreciated


Imports System.IO
Imports System.Drawing

Public Class Resize_File
Public Padding As Boolean
Public fileType As _FileType
Public Orientation As _Orientation
Public JPGQuality As Integer

Public Interpolation As Drawing.Drawing2D.InterpolationMode
Public SmoothingMode As Drawing.Drawing2D.SmoothingMode

Private sourceFile As Bitmap
Private convertedFile As Bitmap
Private newGraphic As Graphics
Private sourceType As String
Private convertedType As String
Public Enum _Orientation
Portrait = 0
Landscape = 1
End Enum
Public Enum _FileType
BMP = 0
GIF = 1
JPEG = 2
PNG = 3
End Enum
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend