0

I have a table called Company with a single column CompanyNames.

I have 17 company names in this column as:

Bahria Town Projacs/TPMS Habib Rafique PCA Wilsons MLDB All Orient 
Extreme Engineering Prime Engineering Method Rousing co Atlas Pakistan 
Bemsol EDL Deep Well Emaad In Situ

Now I want to insert an empty row at the top of these company names.

Can you guys please help me write sql-query which will solve my problem?

Thanks.

4
  • 3
    Why do you need blank record on the top only?? Means If you query then you can have blank records at TOP irrespective of insertion. Commented Jun 19, 2013 at 10:51
  • you can make the blank value on top on select statement. Commented Jun 19, 2013 at 10:52
  • 3
    There is no "top of values" in SQL. This is something you need to handle in your display logic. Commented Jun 19, 2013 at 10:57
  • 1
    Strictly speaking, there is no such concept as "empty row" in SQL. A row consists of one or more columns; a column can allow or disallow NULL. A column of a particular row might be considered "empty" if it contains NULL. There is also the zero-length string [''] which is sometimes used in columns that contain text (varchar) to convey some arbitrary (non-SQL) meaning such as "known to be unavailable" to distinguish it from NULL. Commented Jun 19, 2013 at 11:21

3 Answers 3

4
insert into Company (CompanyName)
values ('')
Sign up to request clarification or add additional context in comments.

1 Comment

By the way, there is no such thing as 'on top of' because the data in the database is not sorted in any particular order when it stored (unless you specify that using a clustered index) and you will need to do a order by to put the empty entry at the top.
1

create another table with Columns ---CompanyName and row number

update Company1 set id=null
WHERE id % 2 = 1;

update Company2 set id=null
WHERE id % 2 != 1;

using even odd values to set null May be this will help if u got what i am saying.

Comments

1

What is the motivation behind wanting have an empty row. Looks to me like it is an attempt to solve problem at a different area in data store. I had experience of being asked such question at work. Like, to show an empty value in Select element on HTML page.

Please tell what is the actual problem you are trying solve.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.