473,372 Members | 1,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

dynamic column creation

hello , i have a doubt , see my requirement is to add a new column to an existing table such tat the column name should be automatically given the name of the variable . i wrote the query as
Expand|Select|Wrap|Line Numbers
  1. alter table test add'+@count+' int
, but i am getting error any idea how to solve this , waiting for your reply
Jun 6 '12 #1

✓ answered by Rabbit

You create a table with a field for the URL and all your attributes. Then you have one row per image.

10 2029
What error you got?

Please Put the Space between add and '+@count+'.
Jun 6 '12 #2
Expand|Select|Wrap|Line Numbers
  1. Incorrect syntax near '+@count+'
.
this is the error which i got .
Jun 6 '12 #3
Please send the function Coding you wrote to alter the Table.
Jun 6 '12 #4
Rabbit
12,516 Expert Mod 8TB
I have one question. Why? It sounds to me like you're breaking the rules of normalization but I can't be sure until I know the reason you need to do this. But I strongly suspect that is the case, in which case, don't do it, you're just making it more difficult for yourself down the line.
Jun 6 '12 #5
ck9663
2,878 Expert 2GB
You have to build a string for the whole statement and execute the string using EXEC. Here read some of this...

Happy Coding!!!


~~ CK
Jun 6 '12 #6
well , in my case i have to insert the url of the image inserted by the user into the db , so i wanted to create a new column every time a user inserts a new url . i think it ll make things easier for me while retrieving the value of url .
Jun 7 '12 #7
i even tried usig exec but still getting the same error , i don't think it ll make any difference in coding
Jun 7 '12 #8
Rabbit
12,516 Expert Mod 8TB
You're definitely breaking the rules of normalization. Every time the user adds a new URL, insert a new row, don't create a new column every time. You should have a URL table and just keep adding rows to that. What you're trying to do now will only make querying a nightmare later on.
Jun 7 '12 #9
well , my full requirement is like i ll add a new image and edit its attributes like width, height , once this is done , i ll add that image url as column and attributes as column values , then get its attributes by using select 'image url' from the table ... do u have any idea how to do this
Jun 8 '12 #10
Rabbit
12,516 Expert Mod 8TB
You create a table with a field for the URL and all your attributes. Then you have one row per image.
Jun 8 '12 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tompa | last post by:
Hi, I would like to create images on the fly as a response to an http request. I can do this with PIL like this (file create_gif.py): from PIL import Image, ImageDraw print 'Status: 200 OK'...
1
by: andrew queisser | last post by:
I've been trying to dynamically create a class DevT that's derived from a generic base GenBase<T>. It doesn't seem to work. I'm attaching a code sample below that illustrates the problem. ...
2
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page....
0
by: Mark Parter | last post by:
I'm adding a dynamic column to a gridview control at runtime but I'm encountering a problem whereby I can only add 1 item to the column header. The column header should show the date in the...
8
by: william_dean | last post by:
Hello, I've done some searching around the post, and I have found quite a bit of information related to the setAttribute and it's related uses. My problem lies in the usage of colspanning in dynamic...
1
by: None | last post by:
Dynamic array creation Hi all... here's a good one for you... I have a situation where I have some bean, and I need to populate an array field in it... here's the problem... I do not know the...
1
by: Nagaraj | last post by:
Hello All, My Problem: Dynamic column – Example, if there is an Employee details, I should able to add or remove columns very easily. Selected Model: Meta-data model – storing all the values...
1
by: mitramay | last post by:
I am creating a dynamic datagrid. The controls in some of the template columns will have to be generated based on the data contained in them (i.e. the data for that respective DataField column)....
0
by: KA NMC | last post by:
I have a dataGrid that is populated by SQL table. The Datagrid has two dynamic columns - that I created to for calculations. I want to sort the grid on frmload by one of the dynamic columns is that...
3
by: arunank | last post by:
Hi, The following code for dynamic table creation is not working. Can anyone please help me. The dynamically created rows and columns are not getting populated. CODE: ========= <html>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.