Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Create dynamic column into table and insert value

Author  Topic 

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2010-12-29 : 04:35:34
Hi,

I want to insert rows into table but columns may or may not be exists into table so how row will insert if column not exist because column depends upon front end application that is in .NET.Can it be happen by pivot table to insert rows.please suggest me.

Thanks,

Ranjeet kumar singh

Ranjeet Kumar Singh

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-29 : 04:42:49
>> how row will insert if column not exist
What do you want to do with the data for the missing columns?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2010-12-29 : 15:34:45
>> I want to insert rows into table but columns may or may not be exists in the table so how row will insert if column not exist because column depends upon front end application that is in .NET.Can it be happen by pivot table to insert rows.please suggest me. <<

Please read any book on basic RDBMS and SQL. Tables have a fixed, known set of columns. They do not change shape. You can use DEFAULTs to complete the rows.

Good SQL programmers do not use PIVOT and they knwo it is not really a table at all.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page
   

- Advertisement -