April 2, 2009 at 1:31 pm
Hello All,
How can I stop the date that have been entering automatically in row?
For example, I have three rows but different columns
A B C
I have entered the date for column A is 11/1/2008, then I wish to not enter the dates for column B and C. I wish to leave them blank, but somehow it automatically enters the present date which is today date 4/2/2009.
A B C
11/1/2008 4/2/2009 4/2/2009
I don't want to have the dates in the column B & C (as SQL server enters automatically).
How can I stop them to enter present date? Unless I want to put it there.
Thank you
Joseph
April 2, 2009 at 1:49 pm
josephptran2002 (4/2/2009)
How can I stop the date that have been entering automatically in row?
Remove the default that's on the column.
In management studio, design the table (object explorer, right click the table, design), find the column in question. Select it. Find where the default is set. Remove it. Save the table.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2009 at 2:20 pm
... and have a look for triggers on your table.
Greets
Flo
April 2, 2009 at 2:32 pm
Hello there,
How can I remove the default? would you please tell me specific steps that I should do?
Sorry I am new to this
Thank you so much
April 2, 2009 at 2:34 pm
Right click -> delete...
April 2, 2009 at 3:03 pm
Oh no
How can I locate the default of specific column in the table?
I know how to delete
Thank you
🙂
April 2, 2009 at 3:34 pm
josephptran2002 (4/2/2009)
How can I locate the default of specific column in the table?
In the table designer click on the column. At the bottom of the screen is a list of properties. Close to the top is 'default value or binding' Click on that. Delete whatever's there. Save the table.
See attached.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2009 at 5:15 pm
Hello Gila,
Thank you very much, you are the man and thank you for teaching me how to solve SQL issues.
I have a question which relates to SQL
First, how can you attach a file to this post?
Second, I typed the codes for creating a table with sample data, and try in table query and it worked. But when I try to create in this forum to create a table with sample data, so I can get better help from expert like you in this forum but I could not do it.
This is what I have done
I click on IFCode shortcuts :" " and pasted the codes (where I have run in the SQL window, it worked) between
but I won't create a table with the sample data in this forum.
Thank you
Joseph Tran
April 3, 2009 at 3:12 am
I don't understand what you're struggling with.
To post a sample table, paste the CREATE table statement into the edit window, like this:
CREATE TABLE [dbo].[LargeTable](
[ID] [int] NULL,
[SomeString] [char](6) NULL,
[RandomDate] [datetime] NULL,
[Big] [varchar](1000) NULL
) ON [PRIMARY]
Then you write some insert statements for that table to populate it with your sample data, like this.
INSERT INTO LargeTable Values (1,'abc','2008/01/01','abc')
INSERT INTO LargeTable Values (2,'def','2008/02/03','tre')
etc
Have you considered taking a SQL training course, buying a good book, going through online tutorials? You've been saying for 4 months or so that you're new at this, but you don't appear to be trying to get the skills that you currently lack.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 3, 2009 at 6:01 am
Hello Gila,
Thanks for the comments, I do know how to write simple query like you told me so. But I don't know how to post the table with sample data in this forum. That why I am asking you to show me how?
Again, thank you so much for your efforts.
April 3, 2009 at 6:32 am
Hey there,
{mode=psychic}
Assuming you have a DEFAULT constraint on the columns set to GetDate() or CURRENT_TIMESTAMP or GetUtcDate(), and that you are using the table editor in Management Studio to enter new rows:
If you leave a cell blank, SQL Server will add to default value for you (as you asked it to by adding the DEFAULT). If the column allows NULLs, and that is what you wish to insert, pressing CTRL+0 (that's a zero) will explicitly enter a NULL, if memory serves.
To add a table definition to a post, simply script the table to the clipboard in Studio, then paste into the text (here) as you are entering your next post.
If any of that is unclear, I would also urge you to browse online resources, take a course, read a good book etc etc. 🙂
Cheers,
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 3, 2009 at 7:36 am
josephptran2002 (4/3/2009)
But I don't know how to post the table with sample data in this forum. That why I am asking you to show me how?
I just showed you how. Exactly as I did it in my post.
The table:
CREATE TABLE [dbo].[LargeTable](
[ID] [int] NULL,
[SomeString] [char](6) NULL,
[RandomDate] [datetime] NULL,
[Big] [varchar](1000) NULL
) ON [PRIMARY]
The sample data:
INSERT INTO LargeTable Values (1,'abc','2008/01/01','abc')
INSERT INTO LargeTable Values (2,'def','2008/02/03','tre')
That's it. Nothing more complex than putting the CREATE TABLE and INSERT statements in your post. Exactly as I have just done with the table LargeTable.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 3, 2009 at 8:45 am
Hello Paul,
Thank you for your helps, I already got the answer for it. Anyway, Thank you so much.
Very Respectful
Joseph
April 3, 2009 at 8:54 am
josephptran2002 (4/3/2009)
Thank you for your helps, I already got the answer for it. Anyway, Thank you so much.
That's good news! And you're welcome, though I was just guessing...
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply