Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Sunday, February 19, 2012

Default Value in Date Field

I am trying to put today's date into a DateTime field in a table. Is there
something I can put in the Default Value property of that field to do this?
I used to do this in Access, but can't figure it out in SQL Server.
Thanks in advance,
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health SystemExample:
use northwind
go
create table dbo.t (
colA datetime not null constraint df_colA default (getdate())
)
go
insert into dbo.t default values
go
select * from dbo.t
go
drop table dbo.t
go
AMB
"chuckdfoster" wrote:

> I am trying to put today's date into a DateTime field in a table. Is ther
e
> something I can put in the Default Value property of that field to do this
?
> I used to do this in Access, but can't figure it out in SQL Server.
> Thanks in advance,
> --
> Chuck Foster
> Programmer Analyst
> Eclipsys Corporation - St. Vincent Health System
>
>|||You can put GETDATE() in the Default Value property.
Jacco Schalkwijk
SQL Server MVP
"chuckdfoster" <chuckdfoster@.hotmail.com> wrote in message
news:u4jXEqZSFHA.1268@.TK2MSFTNGP14.phx.gbl...
>I am trying to put today's date into a DateTime field in a table. Is there
> something I can put in the Default Value property of that field to do
> this?
> I used to do this in Access, but can't figure it out in SQL Server.
> Thanks in advance,
> --
> Chuck Foster
> Programmer Analyst
> Eclipsys Corporation - St. Vincent Health System
>|||create table mytable (
a int,
b smalldatetime default getdate()
)
insert into mytable (a) values (1)
select * from mytable
a | b
___________________
1 | 2005-04-25 15:36:00
"chuckdfoster" <chuckdfoster@.hotmail.com> wrote in message
news:u4jXEqZSFHA.1268@.TK2MSFTNGP14.phx.gbl...
>I am trying to put today's date into a DateTime field in a table. Is there
> something I can put in the Default Value property of that field to do
> this?
> I used to do this in Access, but can't figure it out in SQL Server.
> Thanks in advance,
> --
> Chuck Foster
> Programmer Analyst
> Eclipsys Corporation - St. Vincent Health System
>|||Hi
Use GETDATE() : For current systemdate and
GETUTCDATE() : for current GMT
Aneesh
"chuckdfoster" <chuckdfoster@.hotmail.com> wrote in message
news:u4jXEqZSFHA.1268@.TK2MSFTNGP14.phx.gbl...
> I am trying to put today's date into a DateTime field in a table. Is
there
> something I can put in the Default Value property of that field to do
this?
> I used to do this in Access, but can't figure it out in SQL Server.
> Thanks in advance,
> --
> Chuck Foster
> Programmer Analyst
> Eclipsys Corporation - St. Vincent Health System
>|||Thank you! Those where exactly what I needed!
Chuck Foster
"Kasper Birch Olsen" <kasper@.nospam.com> wrote in message
news:%23g%23JEwZSFHA.2348@.TK2MSFTNGP09.phx.gbl...
> create table mytable (
> a int,
> b smalldatetime default getdate()
> )
> insert into mytable (a) values (1)
> select * from mytable
> a | b
> ___________________
> 1 | 2005-04-25 15:36:00
>
> "chuckdfoster" <chuckdfoster@.hotmail.com> wrote in message
> news:u4jXEqZSFHA.1268@.TK2MSFTNGP14.phx.gbl...
there
>

Friday, February 17, 2012

Default Value - I see the finish line!

Third Posting on how the heck Report Manager sets the "Has Default" property,
specifically the method it uses. Current, RS drops that property when you
copy a report, hence making Snap Shots impossible when Snapping a copy of
another report. I'm doing this in an application.
Comon someone, I get this down and this baby gets thru QA!!!
My kingdom for the answer!!
thank you in advanceTake a look at
http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_ir_5zec.asp
for working with ReportParameter Objects
and
http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_48jc.asp
for how to call SetReportParameters method.
Some examples for working with report parms can be found on:
http://groups.google.com/groups?q=SetReportParameters&hl=en&lr=&group=microsoft.public.sqlserver.reportingsvcs&selm=OlRQmQDuEHA.3860%40TK2MSFTNGP09.phx.gbl&rnum=8
http://groups.google.com/groups?hl=en&lr=&frame=right&th=3c7cb0c51785eb58&seekm=9F17B95C-B484-46D9-A7F0-FD7BE91DE8EB%40microsoft.com#link7
Suspect you need to 1st call GetReportParameters against old report to
obtain parameters, then SetReportParameters against copy fo the report you
are making.
--
-- "This posting is provided 'AS IS' with no warranties, and confers no
rights."
jhmiller@.online.microsoft.com
"Eddie" <Eddie@.discussions.microsoft.com> wrote in message
news:6320E87B-95CA-4DA7-85FB-B2FCF05198E2@.microsoft.com...
> Third Posting on how the heck Report Manager sets the "Has Default"
> property,
> specifically the method it uses. Current, RS drops that property when you
> copy a report, hence making Snap Shots impossible when Snapping a copy of
> another report. I'm doing this in an application.
> Comon someone, I get this down and this baby gets thru QA!!!
> My kingdom for the answer!!
> thank you in advance|||John,
I do as the docs and you speak of. The twist is, you can't set a default
value if the report does not have the "has default" check box ichecked. It
works great if that darn check box is checked. Unfortunately, when you do a
Copy of a report, using CreateReport(), it for some reason loses the "Has
Default" property, meaning you can't progamatically set it, and hence, cannot
create a snapshot from it. I know it's possible, since you can do it in
Report Manager. What I can't figure out is how to progamatically set the "Has
Default" property of the parameter. The "Has Default" property is not listed
as a public of the ReportParameter Class.
"John H. Miller" wrote:
> Take a look at
> http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_ir_5zec.asp
> for working with ReportParameter Objects
> and
> http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_48jc.asp
> for how to call SetReportParameters method.
> Some examples for working with report parms can be found on:
> http://groups.google.com/groups?q=SetReportParameters&hl=en&lr=&group=microsoft.public.sqlserver.reportingsvcs&selm=OlRQmQDuEHA.3860%40TK2MSFTNGP09.phx.gbl&rnum=8
> http://groups.google.com/groups?hl=en&lr=&frame=right&th=3c7cb0c51785eb58&seekm=9F17B95C-B484-46D9-A7F0-FD7BE91DE8EB%40microsoft.com#link7
> Suspect you need to 1st call GetReportParameters against old report to
> obtain parameters, then SetReportParameters against copy fo the report you
> are making.
> --
> -- "This posting is provided 'AS IS' with no warranties, and confers no
> rights."
> jhmiller@.online.microsoft.com
> "Eddie" <Eddie@.discussions.microsoft.com> wrote in message
> news:6320E87B-95CA-4DA7-85FB-B2FCF05198E2@.microsoft.com...
> > Third Posting on how the heck Report Manager sets the "Has Default"
> > property,
> > specifically the method it uses. Current, RS drops that property when you
> > copy a report, hence making Snap Shots impossible when Snapping a copy of
> > another report. I'm doing this in an application.
> >
> > Comon someone, I get this down and this baby gets thru QA!!!
> > My kingdom for the answer!!
> >
> > thank you in advance
>
>