.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

Re:Table Names with specified columns

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :Sql Server

Hi All,

I have a column called createdate in my DBtables.

I want a query which pull me all the tables in DB which has this column name and if the column name doesnt present it has to return null

the o/p shd be like this

tablename  columnname

table1             createdate

table2             createdate

table3             null

table4             createdate

table5             null



View Complete Post

More Related Resource Links

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Entity Data Model and database view returning the same columns as there are in a table


When adding a stored procedure into the Entity Data Model I can select whether the procedure returns a scalar, a (new) complex type or one of the entity types I already defined. 

How do I do something similar for a view?

I mean assuming I have a view like this

CREATE VIEW FilteredFoos as SELECT Foo.* FROM Foo join ... WHERE ...

(that is a view that implements some involved filtering, but returns all columns from one table) how do I add it to the project so that I can use the entity set, but get the Foo objects, not some new FilteredFoo objects.

var foos = myDB.FilteredFoos.Include("Bar").ToList();

foreach (Foo foo in foos) { ...

Thanks, Jenda

Can two columns have the same display names but different underlying names?


I have two columns which are set up differently. But for a display purpose and different usage, they should share the same display names but not the underlying name. How may I set them up in SharPoint?

How to create scrolling table for columns in a SharePoint Designer Data View


I have a fairly complex SharePoint Designer 2007 Data View they have added two more requirements.

1. Have the columns on the right side be able to scroll left to right as there is a large number of columns, while the first 3 columns on the left side stay locked in place.  This is only one list not two, and because of some other requirements I have it must remain to be just one list.

2. Then they also need to have scrolling up and down of the entire list with the headers locked in place.

The first requirement is more important than the second, but preferrably I need to do both.

I am new to XSL so not familar with the syntax. Is this something I can do on a custom Data View? Does anyone have any examples of how?

I have a drawing that show how it needs to look but I don't see an option here to upload a graphic.

So here is a link to my graphic example uploaded to my blog area: http://lindachapman.blogspot.com/  or just the image here: http://4.bp.blogspot.com/_aB01ue__NvQ/TGL42MOvrGI/AAAAAAAAAA4/c3xP4uCy4BU/s1600/Scrolling.png

I failed to mention that 3/4 of the columns are HTML Calculated fields wh

SMO classes to generate alter table script to add columns

How to generate ALTER TABLE script to add columns using SMO and c#.

Duplicate columns names not allowed - OPENQUERY - OPENROWSET - Error 492

I have a piece of code below which manipulates incoming XML. I understand why it is failing in SQL2005, due to the duplicate name "Process". What i dont understand is why this works fine in SQL2000? We are trying to migrate from SQL2000 to SQL2005 and even if we run SQL2005 in 8.0 compatibility mode we still get the error. Why does it work in SQL2000 and is there anyway to emulate this behaviour in SQL2005? I really do not want to work through +-600 SPs to see if I need to change anything. Thank You declare @Event varchar(255) declare @XML varchar(3000) set @event = '' set @xml = '<OmegaEvent Process="NEWBUSINESS" Type="APPFORM" DateTimeStamp="2010-09-02T06:06:43" Version="3.0"> <APPFORM> <BUSSUNIT>AN</BUSSUNIT> <CATEGORYDESC> </CATEGORYDESC> <CHECKDIGIT>B</CHECKDIGIT> <CLIENTSTATUS> </CLIENTSTATUS> <CONVERSION> </CONVERSION> <DISTRCHANNEL> </DISTRCHANNEL> <EVENTDATE>20100902</EVENTDATE> <EVENTTIME>60643528960</EVENTTIME> <FINALISOR>N</FINALISOR> <FORM>MIFU</FORM> <FORMNAME>MAX INCOME COMPULSORY</FORMNAME> <INTERMEDCODE> </INTERMEDCODE> <MAIL_CAMPAIGN> </MAIL_CAMPAIGN> <POLICYNO>016058558</POLICYNO> <PROCESS>ICC</PROCESS> <PR

Computed Columns in Table Variables or Table Types

I was just looking for confirmation that computed columns can or cannot be used in a @Table Variable or User-Defined Table Type. I'm trying this: declare @testtable as table(  [testcol] as case when [testcol] = '' then 'a' else 'b' end,  [testcol2] varchar(100) ); insert into @testtable select '','someval' insert into @testtable select 'c','someval2' select * from @testtable It all parses fine, but during the first insert an error is returned Msg 402, Level 16, State 1, Line 2 The data types void type and varchar are incompatible in the equal to operator. Thank you, Paul

Mark columns as Identity in multi-table views?

Hello! When you create a view of one table (i.e. SELECT * FROM Table), it marks the table's identity column as an identity col in the view as well. I have a few that selects columns from several nested tables, but they are all related in a main identity column I select as well, but SQL Server doesn't mark this column as identity, is there a way to do it?Shimmy

Want to show FormView in Edit mode with specific table columns depending on their Genre??

hi, I have  a table in my database called "Profiles". This holds data on Female and Male personal characteristics. On my aspx, I have a formview in edit mode which is binded to an object data source with a GetDataByUserId Select method which retrieves data from the "Profiles" Table via a DAL. The "Profiles" table has some columns which relates to females only and some just males and some are generic to both. See example below     UserId - / of Type GUID GenreId /  of Type BOOL. Hip Size (For females) Dress Size ( For Females) ChestSize (For Men ) TrouserSize (For Men) Weight ( For both )   When the User logs in , they go to an update Page which has the Formview in Edit Item Mode and contains drop down Lists which are binded to the Users Selected Value. The DDL are in turn bound to their related table such as HIP, Dress, Chest, Trouser etc. Objective If a female user logs in I just want to show them the (Hip Size) DDL  and DressSizeDDL in the Edit item template of the formview and not the ChestSize DDL or  TrouserSize DDL. At present the GetProfileByUserId returns all colums from the table My question is how do I do this and just show DDL which are relevant to the Female or Male Only. In some cases the user may not have selected an item in the previous form so they could also be

changing table columns collations

hi i have a database with "SQL_Latin1_General_CP1_CI_AS" collation i changed it to "Persian_100_BIN" but none of columns collations is not converted to "Persian_100_BIN" and remained in "SQL_Latin1_General_CP1_CI_AS" collation. how i can change all columns collations to "Persian_100_BIN"? tank u.

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. 

To Search a word in all the columns of a Single Table

Dear Friends, How can I search a word in all the columns of a table?Please advise.

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&

Move columns in table using BIDS?



Call me crazy, but I can't figure out how to do something as simple as change the order of the columns in a report without cutting and pasting. Is there someway to reorder columns easily? Say like drag and drop like every other grid on the face of the planet supports?


Arrange columns from nested table in a dataset that writes into XML file



I have 3 related data tables. I added these tables into a dataset and finally write it to a XML file. But the related columns from table 2 and 3 is appended after all the columns from table 1. How can I have something like:
in a dataset that I write to XML instead of

How to play around with Columns' names filled by OleDbDataAdapter ?


I tried to query an excel file which contains a lot of customers' information but my problem is most of those don't have a specific column names.

E.g. it's in the following format. (Excel File)

A         B         C

Info1  blur    blur
Info2  blur    blur
Info3  blur    blur

So, when I query using SqlDbDataAdapter, in my DataTable, info1 blur blur becomes column header.

E.g. it's in the following format. (DataTable)

Info1 blur blur

Info2 blur blur
Info3 blur blur

I been working on it so that it actually goes down one row and Change the column name in the DataTable into some appropiate name. Something like the following format.

Name1  Name2  Name 3

Info1       blur        blur
Info2       blur        blur
Info3       blur        blur

Is there any way that I could work around it rather than actually going back to change the excel files ? Because I have like 1,000 excel files in that kinda format and s

It is possible to alter multiple columns within a single alter table statement?


It is possible to alter multiple columns within a single alter table statement?

I tried & searched not getting it.

Alter table au_de alter column m_user char(9),c_user char(9)

Msg 102, Level 15, State 1, Line 1

Incorrect syntax near ','.


Alter table au_de alter column m_user char(9),alter column c_user char(9)
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ','.

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