Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Thursday, March 29, 2012

environment variable

hi,

can you show me how to get the value of an environment variable from a script task?
thanks!

Try Environment.GetEnvironmentVariable method
http://msdn2.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx|||

Public Class ScriptMain
Public Sub Main()

Dim home As String = System.Environment.GetEnvironmentVariable("HOMEDRIVE") + System.Environment.GetEnvironmentVariable("HOMEPATH")

Dts.Variables("MyDocuments").Value = Path.Combine(home, "My Documents\")

Dts.TaskResult = Dts.Results.Success
End Sub

There is a sample package that illustrates the method in action here -

Environment Variables- Raw Files
(http://wiki.sqlis.com/default.aspx/SQLISWiki/EnvironmentVariables-RawFiles.html)

Tuesday, March 27, 2012

enumerate suffixes and counts in varchar column

I have a column of VARCHAR values for which each value may contain one of
more dashes ("-" character). I would like T-SQL that enumerate all the
possible values following the FINAL dash character and counts the number of
occurrances of each and loads these into another table (2 col table :
Suffix[nvarchar] and Count[int])First, the obligitory note of reason. Storing data like this is generally a
bad idea. If you need to use substring on a value then it probably needs to
be > 1 columns. Maybe not in your case, but I figure that the dashes aren't
a random pattern, right?
Second, this will give you the result, I think...
create table test
(
value varchar(20)
)
insert into test
select 'hds-f-dsafsaf-asf'
union all
select 'asdfasdfads'
union all
select 'asdfads-asdfas-as'
union all
select 'isd-asd'
go
select case when charindex('-',value) > 0 then
substring(reverse(value),1,charindex('-',reverse(value))-1)
else ''
end
from test
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:Oxjgp2QLGHA.904@.TK2MSFTNGP10.phx.gbl...
>I have a column of VARCHAR values for which each value may contain one of
>more dashes ("-" character). I would like T-SQL that enumerate all the
>possible values following the FINAL dash character and counts the number of
>occurrances of each and loads these into another table (2 col table :
>Suffix[nvarchar] and Count[int])
>|||Yes, I agree. Very bad data structure. Not my idea.
You're code looks interesting, but I also need a count of each distinct
suffix (where a distinct suffix is defined as one that follows the final
dash ("-") character.
"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:%23hLtR%23QLGHA.2416@.TK2MSFTNGP15.phx.gbl...
> First, the obligitory note of reason. Storing data like this is generally
> a bad idea. If you need to use substring on a value then it probably
> needs to be > 1 columns. Maybe not in your case, but I figure that the
> dashes aren't a random pattern, right?
> Second, this will give you the result, I think...
> create table test
> (
> value varchar(20)
> )
> insert into test
> select 'hds-f-dsafsaf-asf'
> union all
> select 'asdfasdfads'
> union all
> select 'asdfads-asdfas-as'
> union all
> select 'isd-asd'
> go
> select case when charindex('-',value) > 0 then
> substring(reverse(value),1,charindex('-',reverse(value))-1)
> else ''
> end
> from test
>
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
> "Arguments are to be avoided: they are always vulgar and often
> convincing."
> (Oscar Wilde)
> "John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:Oxjgp2QLGHA.904@.TK2MSFTNGP10.phx.gbl...
>|||Here is the complete solution. Hope this helps get you going...
create table test
(
value varchar(20)
)
insert into test
select 'hds-f-dsafsaf-asf'
union all
select 'asdfasdfads'
union all
select 'asdfads-asdfas-as'
union all
select 'isd-asd'
union all
select 'isd3-asdfa-asd'
go
select suffix, count(*)
from ( select reverse(case when charindex('-',value) > 0 then
substring(reverse(value),1,charindex('-',reverse(value))-1)
else ''
end) as suffix
from test ) as suffixValues
group by suffix
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uhJPFDRLGHA.2668@.tk2msftngp13.phx.gbl...
> Yes, I agree. Very bad data structure. Not my idea.
> You're code looks interesting, but I also need a count of each distinct
> suffix (where a distinct suffix is defined as one that follows the final
> dash ("-") character.
>
> "Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
> news:%23hLtR%23QLGHA.2416@.TK2MSFTNGP15.phx.gbl...
>

entry number thousand from 3 Tables with primary key number

Hi!
I have 3 tables with a primary key (number integer 4 ) and I have a datetime
field date_ (datetime 8) with the following value: 16.01.2003 00:00:04.
The primary key is not starting with one and some numbers are also missing.
Now I want to get the entry number thousand in the order after the date_
field with all rows from this 3 tables.
How must my select statement look like?
ThanksCan you further elaborate the following sentence:
Now I want to get the entry number thousand in the order after the date_
field with all rows from this 3 tables.
"Hubert Mayr" <huma1@.gmx.net> wrote in message
news:1068474664.222762@.news.liwest.at...
> Hi!
> I have 3 tables with a primary key (number integer 4 ) and I have a
datetime
> field date_ (datetime 8) with the following value: 16.01.2003 00:00:04.
> The primary key is not starting with one and some numbers are also
missing.
> Now I want to get the entry number thousand in the order after the date_
> field with all rows from this 3 tables.
> How must my select statement look like?
> Thanks
>

Wednesday, March 21, 2012

Enterprise manager table design

I have table with more then 100 columns . I must change default value
from 0 to 1 in 90 columns. Is there a way to do this in "table design"
in "all in once" metod.Hi
Please don't multipost , I've answered the question in .programming group.
"nywebmaster" <scgwebmaster@.yahoo.com> wrote in message
news:1131349183.821846.143180@.o13g2000cwo.googlegroups.com...
>I have table with more then 100 columns . I must change default value
> from 0 to 1 in 90 columns. Is there a way to do this in "table design"
> in "all in once" metod.
>

Sunday, February 19, 2012

Enterprise Manager ... inserting <NULL> value.

What is the keyboard shortcut for entering a <NULL> into a database field from within the Enterprise Manager? I've done it before, but can't remember it for the life of me! Also, is there a query that I can use to insert <NULL> in place of ''?Run...as fast as you can ...away from EM...

Just don't put anything in there....

EDIT: It's [CTRL]+0|||Originally posted by Brett Kaiser
It's [CTRL]+0 Thanks!|||Now do yourself a favor and stop using EM and start using QA|||I'm a SQL newbie ... forgive my ignorance. I find it easier to use EM since it's graphical and I can enter/edit information on screen vs. writing queries. Since this DB is in development, this doesn't pose any locking issues.|||Well, if you learn to do it right while you're developing, when you go to production you will have a set of tools for troubleshooting data that you will find yourself going to EM to do otherwise.

You really shouldn't use EM ever for any reason. We continually tell people that because basically the tool sucks. :)

Wednesday, February 15, 2012

Entering a Guid in Enterprise Manager

A very simple question...
When I edit the data in a table how can I enter a Guid value in Enterprise
Manager?
I've tried:
{AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}
AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
nothing works!
Hi
{E5215E35-1D3B-40B1-9F8E-A0B7BEF39F03} works perfectly for me
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"sm" <sm@.smith.com.invalid> wrote in message
news:%23PkcSZpSFHA.2124@.TK2MSFTNGP14.phx.gbl...
>A very simple question...
> When I edit the data in a table how can I enter a Guid value in Enterprise
> Manager?
> I've tried:
> {AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}
> AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
> 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
> nothing works!
>
|||Thanks.
Actually generating a Guid in registry format with guidgen.exe (Visual
Studio Tools menu) and then pasting it in the column doesn't seem to work.
It's probably because of a carriage return.
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:ecp1cBqSFHA.2872@.TK2MSFTNGP14.phx.gbl...
> Hi
> {E5215E35-1D3B-40B1-9F8E-A0B7BEF39F03} works perfectly for me
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "sm" <sm@.smith.com.invalid> wrote in message
> news:%23PkcSZpSFHA.2124@.TK2MSFTNGP14.phx.gbl...
>

Enter Parameter Value

Hey in Access MDB you can create a query that when you run it, it will ask you to Enter the Paramer Value, User could enter in a year or Team Member Number or however you have the query set up. is this possible in SQL ADP?No, not in SQL. Prompting the user for input is the responsibility of the interface, not the database engine. Access has an interface packaged with the engine. SQL Server is purely a database engine.

Your ASP page will need to check the stored procedure to determine which parameters are required and provide a means for the user to enter them.|||Thank you Blindman, wasnt sure|||How have you been??|||I actually think that an ADP (Access Data Project) can do interactive prompting, but I'm not sure how to make that happen. Since all of the ADP code actually runs on the client (either via the web page or within the project itself), I don't see any problem...

I'll have to experiment and see if I can finger out how to make this fly, but it won't be today.

-PatP|||Yeah I was hoping there would be a way of doing that, I'll have to do some investigating. It would make things a little easier for me though|||Even if you could find a way to automate this at the ASP layer, wouldn't it be limited to prompting for the often cryptic parameter names specified by the procedure developer?

Not very user friendly...|||I'm not sure what ADP projects to ASP. I think that Desiree is looking for a pure ADP configuration at least for now. I'll investigate both ADP and how it projects into ASP though.

-PatP|||ADP ASP ADP ASP ADP ASP ADP ASP...

Oh. aDp!

<Mild embarrasment./>|||I've never had that happen, but I read about it in this book once... ;)

-PatP|||When I open up a stored procedure in an Access Data Project it does prompt me for the parameter.