|
When you add new fields, set a default value for the column. If you don't do that, you can't add the column at all, and if you do, then that default value will appear for all existing records. The alternative is to make the columns nullable and then they will default to null, but then you need to deal with null in all your code for new columns, so a default value is better. Null WILL tell you that a column was not there before, if your own code never inserts null, if that is worth the work to make it happen that way.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
tell me how can i add new column in existing table ..i need query of this task brothers... actually i want add new column of datatype of identity...
so plzz tell me query..
thanks 2 all..
|
|
|
|
|
Hi,
To add a column to an existing table, the ALTER TABLE syntax is:
------------------------------------------------------------------
ALTER TABLE table_name
ADD column_name column-definition
For example:
ALTER TABLE NewField
ADD TableName INT IDENTITY(1,1)
------------------------------------------------------------------
This will add a column called NewField to the TableName table.
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
thanks brother..
thanks 2 all..
|
|
|
|
|
Hi all,
I need to create a temporary table for the results of my select statement in sql server 2005.
Here is my SQL statement which does the select :
SELECT
DISTINCT
IM.MENU_ID AS 'StructureId',
IM.MENUITEM_ID AS 'CategoryId',
EA.Title AS 'Name'
FROM
HN_IM_JOIN IM
INNER JOIN HNIM_ElementAttributes EA
ON EA.OwnerId = IM.MENUITEM_ID
INNER JOIN HNIM_Element EL
ON EL.ID = IM.MENUITEM_ID
WHERE EA.Lcid = 'en'
AND IM.MENU_ID = 'bd966aba'
ORDER BY EA.Title
but I want to write these to a temporary table.
Any Idea please
|
|
|
|
|
Try:
SELECT DISTINCT IM.MENU_ID AS 'StructureId',
IM.MENUITEM_ID AS 'CategoryId', EA.Title AS 'Name'
INTO #temp1
FROM HN_IM_JOIN IM
INNER JOIN HNIM_ElementAttributes EA
ON EA.OwnerId = IM.MENUITEM_ID
INNER JOIN HNIM_Element EL
ON EL.ID = IM.MENUITEM_ID
WHERE EA.Lcid = 'en'
AND IM.MENU_ID = 'bd966aba'
ORDER BY EA.Title Regards
Andy
|
|
|
|
|
Which is the best method ( with .net c# vs2005) to develop an application that accesses (read and write) two sql databases stored on different machines (net connection) ?
Thank you
Mauro Savoiardo
|
|
|
|
|
I don't understand what you mean by "best method" in this context. You access a database using a connection. The connection strings will be different. That's the only difference I see between accessing one database and accessing two.
Did you have something specific in mind?
|
|
|
|
|
My problem was about the connection to the database stored on the second machine from an application installed on first one
bye
Mauro Savoiardo
|
|
|
|
|
Member 487672 wrote: My problem was about the connection to the database stored on the second machine from an application installed on first one
Unless I'm missing something I don't see why that is a problem. To connect to the database you use a connection string that tells your .NET application where the database is. It doesn't matter if it is on the local machine or a remote machine, the connection string always needs to say where the database is.
|
|
|
|
|
Hi to everyone!
I have one problem, when I want to make an update to some record in the table, I am entering the data for it, and instead just for one field, the UPdateCommand is putting the same data in all the fields. Example:
I have two fields: ID and Name. And I am making an update of the name, and it's changed all the data for all the fields under Name. I think that I should use some WHERE statement, but I am beginner in SQL and every help will be appreciated. Thx
Example, before update, I had:
ID:1
Name:a
------------
ID:2
Name:b
-----------After update-------------
Update name: "c"
ID:1
Name:c
------
ID:2
Name:c
-------
|
|
|
|
|
you should use
WHERE ID=<your desired="" id="">
|
|
|
|
|
If you donot mention the where clause it updates all the records in a table.
Do good and have good.
|
|
|
|
|
Hi! I want to insert data in the detailsview, and I set my InsertCommand like:
InsertCommand="INSERT INTO name FROM [tblname]" and it gives me mistake: Incorrect syntax near the keyword 'FROM'.
Any help? Thanks
|
|
|
|
|
one more thing: I already solved, but when I am putting this syntax:
INSERT INTO tblname(name) VALUES ('')
it gives me blank field, and what should I do, so the VALUES will fill the name field with data. Thanks
|
|
|
|
|
I solved.
|
|
|
|
|
I am developing a database driven application. I would like to have any insert done by user to be added to the record for security purposes.the problem is having the person logged in pick data from the users table to the inserted record because all users are using the same database with same credentials. Only developed users table in this database
Give the world the best you have, And the best will come your Way
|
|
|
|
|
Hi Xerox4,
Can you please explain your question in brief? I can't understand it properly.
|
|
|
|
|
Hi! I have a database connected with web, and I want the ID field to be fill automatically, like for example I have: ID, user, pass. I will fill the user and pass fields, and the ID field to be filled like with autonumber, incremented by 1.
Thx, Angel
|
|
|
|
|
So, set the column to be an identity field. Am I missing something ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I can't see any option for setting the field of type identity, should i do that with some query. I am new in SQL, thx ahead
|
|
|
|
|
in sql server for numeric feilds you will find the option for indentity property
set this to yes then you have to set the identity seed which is any number from where you want to start the autonumbering and indentity seed the increment to want in each record.
Yogesh Agarwal
|
|
|
|
|
Create table tblname<br />
( id int identity(1,1))
the first standing for the starting number and the second for the increment
Give the world the best you have, And the best will come your Way
|
|
|
|
|
I'm Working with SSRS-2005 Reports in C# Web Applications..
I'm having One Doubt regarding Division..
In Chart Control (Pie-Chart Type)
(Properties--> Data--> Values--> (Select Edit)--> EditChartValues--> PointLabels-->Label-Expression)
I'm Using the Following expression..
=Floor((Fields!Price.Value*100)/Sum(Fields! CPU.Value, "DataSet1_AmountDetails")) & "%"
In Chart Control(Pie-Chart Type).. I'm getting Output as..
10%, 15%, 12%, 7%, 27%, 14%, 14% ...
If I'm Using the Following Expression in Chart Control (ie I'm Not Including FLOOR here)..
=((Fields!Price.Value*100)/Sum(Fields!CPU.Value, "DataSet1_AmountDetails")) & "%"
In Chart Control(Pie-Chart Type).. I'm getting Output as..
10.2564789456%, 15.457893652145%, 12.877895632%, 7.9845678987%, 27.12348532%, 14.6547863254%, 14.7550103026% ...
Even I Used ROUND Instead of FLOOR in My expression..
I'm getting my Output as..
10%, 15%, 13%, 8%, 27%, 15%, 15%..
which gives me the Total Percentage is More than 100%.. I want to show my Reports for Only 100%...
This is the Problem i'm facing when i'm Using Round
---------------------------------------------------------------------------------------------------------------
But I Want the OutPut as
10.25%, 15.45%, 12.87%, 7.98%, 27.12%, 14.65%, 14.75%...
How can I do this... Please give me the Suggestions for doing this...
Thank You..
|
|
|
|
|
Specify the number of dps you want to round to. With SSRS, I think the number of dps to round to is passed as the 2nd argument to the Round() function.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|