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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Why are square brackets needed for column names

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :Sql Server
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

View Complete Post

More Related Resource Links

dynamically change column names in Crystal reports


I need to develop 3 pages.

On the first page user defines atmost 7 column names to be displayed on the report. I'm saving these names in a Sql DB table 'Columns' with Column_Nm and Column_ID as Table columns.

On the second page I'm retrieving column_Nm from the table and displaying them on the page so that the user enters the data. This data is saved in another table 'Summary' with the Columns column1 through column7.

on the 3rd page I need to show a report of 'Summary' table.

How do I dynamically replace column1 through column7 names with that of 'Column_Nm' on the report?

Any help/suggestions would be appreciated.


Duplicate column names from forms in SharePoint lists



I'm in the process of migrating from a WSS 2 site to WSS 3/MOSS. On the old site I used an Infopath 2003 form for absence requests. During the migration I now use Infopath 2007. There wasn't any problem initially when the form was stored with the SharePoint form library. However, when I published the form as a content type from Infopath 2007 and then added that content type to the form library, there are two columns for each piece of data from the form. (One from the content type and one from the form list.) I relinked each old form (list content type) to the new AbsenceRequest content type and removed the original one from the list. However, the duplicate column names are still there. Since they came from the Infopath form, they are not editable or deletable from the SharePoint list management interface. The duplicate column names make it tough to build views since it isn't apparent which column to use in the form building UI. It can be determined form the overview display, but it is very cumbersome.


Does anyone know a way to get rid of the old, absolute, columns?

Dynamically change column names in Crystal reports - ASP.Net

Hi I am developing an application in ASP.net 3.0 and MY SQL database . I want to display column names & values in crystal report as user selects in ASP.net application  and column names and corresponding values will be changed dynamically. Any help/suggestions and sample code would be appreciated. Thanks in advance....  

How do I change the order of column names in EditForm.aspx

I have an Announcements list to which I've added extra columns: Publish (date), De-Publish (date), and Category (choice).  When I go to EditForm.aspx, the columns display in this order: Title , Body, De-Publish , Category and Publish . I'd like to change the order of the columns on EditForm.aspx so that it is Title, Body, Category, Publish and De-Publish . Changing the All Items view doesn't do it. How might I change the order of columns that is shown to the user?

Square brackets and Curly brackets

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. 

How to have dynamic column names in an Excel Destination?

I have a situation where both the column names in the source (SQL) and destination (Excel) are being created dynamically. The number of columns, their positions, and datatypes remain the same. How do I change the OLE DB Source and Excel Destination meta-data to handle these changes at run-time?

Column names in each view or function must be unique. Any Suggestions Please!!!!!!!!

I am getting this error when I am executing this view. But I am not getting this Error when parsing the query!!! Can some one help me with the issue. Create   view [PosSales_Transactions_Tenders_Extract] AS SELECT RT .RTL_TRN_ID, RT .STORE_NO, RT .WORKSTATION_NO, RT .RTL_TRN_NO, RT .RTL_TRN_TYPE_CODE, RT .AMOUNT, RT .OPERATOR_NO, RT .CUSTOMER_NO, RT .EMPLOYEE_NO, RT .BUSINESS_DATE, RT .BEGIN_DATETIME, RT .END_DATETIME, TLI .LINE_ITEM_NO, TLI .TENDER_TYPE_ID, TLI .TENDER_TYPE_CODE, TLI .TENDER_AMOUNT, TLI .CHANGE_FLG, TLI .SERIAL_NO, TLI .KEYED_FLG, TLI .EXCHANGE_RATE, TLI .FOREIGN_TENDER_AMT, TE .TENDER_TYPE_ID, TE .TENDER_TYPE_DESC FROM   dbo.RETAIL_TRANSACTION RT JOIN   dbo.TENDER_LINE_ITEM TLI ON   RT.RTL_TRN_ID = TLI.RTL_TRN_ID JOIN   dbo.TENDER TE ON   TLI.TENDER_TYPE_ID = TE.TENDER_TYPE_ID WHERE   RT.VOID_FLG = 0 AND RT .VOIDED_FLG = 0 AND RT .VOIDING_FLG = 0 AND RT .SUSPENDED_FLG = 0 AND RT .TRAINING_FLG = 0 Msg 4506, Level 16, State 1, Procedure PosSales_Transactions_Tenders_Extract, Line 4 Column names in each view or function must be unique. Column name 'TENDER_TYPE_ID' in view or function 'PosSales_Transactions_Tenders_Extract' is specified more than once.

Its posible to do a select without the table and the column names into a stored procedure?



I need your help. Imagine that I have two tables:

  1. ALUMN wich has three columns: IdAlumn, Name and Address.
  2. SPORT wich has columns: IdSport, Name, Players and Description.

Supose that my tables could be differnced by a number 1 is for ALUMN and 2 is for SPORT.

And the columns of each table too. So 1 is for IdAlumn, 2 is for Name and 3 is for Address. 1 is for IdSport, 2 is for Name 3 is for Players and 4 is for Description.

For example the combination of table 2 and column 3 is SPORT-Players.

Then I want to do an stored procedure that receives two parameters (the table, the column) @tab and&

retrieving column names using sql query


hi All
 I have A database in access2007

I want retrieve column names with sql query in my project
I write below code:
"select column_name from information_schema.columns where table_name ='table 1' ORDER BY ORDINAL_POSITION"

but display error :
Could not find file 'D:\Projects\Tapco_ECM\Tapco_ECM\Tapco_ECM\bin\Debug\information_schema.mdb'.

plz help me

Aboslute path needed for hyperlink column



I am working on data datagrid and getting 1 column as Hyper Column 


the Hyperlink Column is declared as 


<asp:HyperLinkColumn DataNavigateUrlField="Path" DataTextField="SongName" 

                    HeaderText="Songs" Target="_self" DataNavigateUrlFormatString="/{0}"></asp:HyperLinkColumn>

where SongName and Path are coming from database



now the values of Path is in the format "http://abc.html"

however when I click on the grid it gives me something like this http://localhost:XXXX/http://abc.html


Please tell me how to convert this relative path to absolute path.

Problem with translation of column names



we have a Sharepoint 2007 Installation with german language packs.

I created a new english site collection and inside the new collection a new document library.
And there I have the problem. The system columns like "modified by" and "modified" have german names: "Geändert von" and "Geändert".

Any idea how I can solve this problem?

Thanks in advance

How to customize column names in Drill through action of SSAS 2005?

Hi Everyone,

Can somebody tell me about:How to customize column names in Drill through action of SSAS 2005?

I have defined drillthrough actions in SSAS 2005 cube. Drillthrough action is working very fine.

But while browsing the cube when i drillthrugh the data, my column names are shown as [$Employee Details].[Employee No], [$Employee Details].[Employee Name] etc.

I want to depict it only as Employee No, Employee Name etc.

Please help...


Help needed with coding an edit column


I have a GridView I've displayed using the following codes:

In the file root/App_Code/ConnectionManager.cs:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;

namespace rankings
    internal sealed class ConnectionManager
        public static SqlConnection GetConnection()
            string connectionstring = ConfigurationManager.ConnectionStrings["yafnet"].ConnectionString;
            SqlConnection connection = new SqlConnection(connectionstring);
            return connection;

In the file root/App_Code/prDAC.

Stored Procedure Column Names - A Suggestion


When a data source calls a stored procedure, you often don't see the column names exposed for mapping in the dataflow designer. There are a number of work-arounds involving SET FMTONLY OFF or setting up a dummy select statement early in the stored procedure, non of which are entirely satisfactory.

Perhaps the SSIS developers could learn something from SSRS here, after the data from a datasource is previewed, the column names are available in the Report Desginer no matter how complex the stored procedure might be.

I would have thought that when you preview the data from the strored procedure in BIDs, that all the required information about the column names and data types returned by the stored procedure could be captured and made available in the data flow designer.

OPENROWSET 'Provider String' Documentation? Firstrow for Text Driver, Column names in 3rd row


I'm using sql server 2008 r2 express and want to write a script to load data from some csv files.


The following gets me close:




        'Driver={Microsoft Text Driver (*.txt; *.csv)}; DEFAULTDIR=C:\Data\QOL;Extensions=CSV;',

        'SELECT * FROM RegistrationData.csv')


The problem is that the that the first two lines are not data (Report Name and time generated) and the third line is the column names. If I manually open the file and delete the first two rows everything comes out perfectly. But there are a number of these files and it has to be done regularly so I want to automate the process.  BULK options allow a FIRSTROW option but that doesn't seem to work w/o the BULK option. Is there a way to effectively skip the first 2 lines w/o the BULK option (and its requisite format file)?

How to get List and Folder Names in a Column Dynamically


We are using MOSS 2007 Farm for our Intranet and we are using it increasingly for Document Management. To achieve this we want to code every Library and Folder and use the code as part of the Document Number. To make this easier for users I have created drop down lists and calculated fields which create the Document Number. Now the number of folders is getting bigger and I would like to filter the lists to assist.

Specifically, I am trying to filter a list based on the document library or folder in which the document is. To do this I tried using the Filtered SharePoint Lookup Field: http://filteredlookup.codeplex.com/ and develop a CAML query along the lines of (I am very new to this!):

      <FieldRef Name="Area" />
      <Value Type="Text">AREA NAME
        <FieldRef Name="Sub Area" />
        <Value Type="Text">SPContext.Current.List["Title"]</Value>

As another wo

OPENROWSET getting column names



I use OPENROWSET  to load excel files with variable number of columns to SQL tables. However, the

columns created in the table have names starting from F1,F2 and so on. Is there a way to define the column names in the SQL table according for example to the first row of excel file?

The excel file has the format : 

Col1 Col2 Col3 Col4 Col5 .....

xx     yy    zz    11    22

I want the created column names using openrowset to be Col1, Col2 etc....Not F1, F2.....

Thanks in advance,


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