.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

Variable number of columns in sql for xml

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :

I have a schema where one of my column in xml can appear 0 or 1 time.

That is fairly easy when it is a subquery. But I don't know how to do it in a main query.

Here is an example of what I want:


View Complete Post

More Related Resource Links

Using Excel Source with variable number of columns



I want periodically to insert data from an excel file into a relational table using a SSIS package. However, each time the number of columns in excel may vary. For example, the 1st time the excel file may have 100 rows the second 105 rows etc.

Can this be done in SSIS and if yes what is the solution?


Thanks in advance,


dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


Embeb a variable number of videos


I need to provide some alternate content for my non-Flash users.

I have a directory of video files that is scanned using the DirectoryInfo() function, and I want to use the results to embed all files ending in ".mov" in QuickTime players on a web form.

How would you approach this? Right now I am using the count on the array of videos to determine how many times to repeat the embed code.  But this seems inelegant.

Is there a way to have a single QuickTime player.ascx control that gets duplicated according to the number of videos available for display?

Abstract method with variable number of paramters

Hi All,Say I have an abstrac method and I want all my Child classes that inherite this method to have different number of input parameters.e.gabtract class Anything { abstract TestFunc() } class Something1 : Anything { TestFunc(string aa) { ... } } class Something2 : Anything { TestFunc(string bb, int cc) { ... } } How would I go about declaring this in my abstract class?

How to know the number of columns displayed on the last page for Multi column table

Hi, How will I determine how many columns to be displayed on the last page of the report if I am using a Multiple column table.  I am going to use the number of columns to multiply with the width of the body of the report. I am going to use a Function to get the product. 

Need help with "ORA-01036: illegal variable name/number" error on SQLDataSource


I keep gettin this error on the Data Source. Any ideas on how to fix this?


<asp:SqlDataSource ID="sdsLastName" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
	<asp:controlparameter ControlID="ddType" DefaultValue="LAST_NAME"  PropertyName="SelectedValue"  ConvertEmptyStringToNull="true" />


How to make number of columns of Gridview depends on a textbox value?


I have a Gridview with 12 columns, Jan, Feb...Dec.
I have a textbox value that could be 1, 2,...12

I want if textbox value is 7, then column Aug-Dec in Gridview is editable when in update mode and the column in Jan-Jul is not updatable (eg make it label instead of textbox).

How can I do this ?


Variable number of colomns in ssrs report



I have a stored procedure which is built on PIVOT fuction. I am using the stored procedure to generate a report.

some time the stored procedure will generate the variable no of colomns, in ssrs dataet is updating with variable no of colomns, at that time report is not supporting.

i am using table control in SSRS. some one suggested me matrix control, but i need to change my stored procedure to work with matirx control.

i dont want to change the stored procedure.

can any one suggest me how to resolve this in SSRS.



count number of columns in group



I need to count number of columns in group -

I have a matrix with SUM in the date area.

I have a group column (lats say 'city') and under it my columns (lats say 'street name');

Under each 'street name' I have cell with SUM function.

The problem is:

When The main group (city) is not expand I get the sum of all cities and what I want to get is an average .

So what I thought of was to divide that number in the number of streets under each city group.

How can I get that number?


rows to fixed number columns


if result is 11 single column rows, need it formatted as 3 rows 4 columns each.  besides brute force, what can I do?


CLR Stored procedures : variable number of input paramters?


Hi there, I've just started looking into CLR stored procedures.

I'd like to create a stored procedure that takes in a variable number of parameters in the same way that sp_executesql does. 

I've tried creating the CLR proc as follows;

using System;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server; 

public class StoredProcedures 
  public static void PriceSum(params SqlString[] parms)


but this results in the following error;

Error	1	Column, parameter, or variable #1: Cannot find data type SqlString[].	StringFactory

so I'm guessing it can't be done. 

Is there a way to mimic sp_executesql ?

DATEADD number as variable


I'm trying to use a variable in the DATEADD(dd, @dt1, GETDATE()).  This always throws an error, it can't convert the variable properly, but even when I do something like DATEADD(dd, CONVERT(int, @dt1), GETDATE()), still error.

Any help is appreciated!

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

add columns with textboxes in gridview using C#

'm working on a shopping cart in a website and I have my items(which have been added to the cart) in an arraylist. And using these values I've read the rest of the values from the db and and have populated on the gridview successfully.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Local variable scoping in C#

In my previous post, Compiler-generated scopes for local variable declarations, I briefly touched on the issue of multiple meanings applied to the same name. In this post, I'll aim to flush out the compiler's rules with regards to binding names in their local scopes.
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