Showing posts with label generate. Show all posts
Showing posts with label generate. Show all posts

Sunday, February 19, 2012

Bulk Copy Program

Hi Techies,

I have a bcp which generates .txt file perfectly. I just wanted to know how can i generate a text file in distributed environment.

Assuming that my Sql Server is running in machine A. I wanted the bcp to generate in Machine B. What are the permission's i should give in order to generate it in Machine B.

Regards
--Tanveerthe user who executes the bcp-command would need write access. read access is usually handy to validate the file has been written but I don't think its required. In case machine B only has a filesystem, that user obviously needs filesystem write access. In case machine B is a sqlserver that user would need write access on the table the file is insert into.|||Thanks for the reply... I guess i have not mentioned that the above program would be executed through stored procedure. In this scenario what are the permission i should give and to which users.

--Tanveer|||Assuming bcp and the copy is executed using xp_cmdshell, the user is the user configured to run sqlserver (exec master..xp_cmdshell 'set'). If it's local user (only known to the server) you'll find it difficult to do the windows-copy. If it's a domain user it'll be easier to grant the write access. Do you have difficulty creating the .txt file using the stored procedure?

Sunday, February 12, 2012

building an .asdatabase file from the command line

Hi,

I was wondering if anyone knew how to 'build' an 'analysis services' project (i.e - generate the .asdatabase file) from the command line, so that I could have it done automatically during a build process.

Thanks,
Kobi Reiter

Play around with the devenv.exe executable at the command-line. Although I have not tried it, you might be able to use it with your project file and with a "/build" option. The executable is the what launches when you run BI Dev Studio. Typical setup has it located at:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Dave Fackler

|||

Unfortunately, when I try to run devenv with the /build switch, it fails:

Package 'Visual Studio Source Control Integration Package' failed to load.
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

|||I'm also interested in this. Need to automate the build of our deployment package. Haven't been able to find any information on this.
|||I am also interested in this topic .... Anyone can contribute any idea(s). Thanks.|||

hello,

i would expect something like the following to work

devenv.exe <your_solution_name>.sln /build Development /Out out.log

Note that you might need an SP1 build for this.

hope this helps,

building an .asdatabase file from the command line

Hi,

I was wondering if anyone knew how to 'build' an 'analysis services' project (i.e - generate the .asdatabase file) from the command line, so that I could have it done automatically during a build process.

Thanks,
Kobi Reiter

Play around with the devenv.exe executable at the command-line. Although I have not tried it, you might be able to use it with your project file and with a "/build" option. The executable is the what launches when you run BI Dev Studio. Typical setup has it located at:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Dave Fackler

|||

Unfortunately, when I try to run devenv with the /build switch, it fails:

Package 'Visual Studio Source Control Integration Package' failed to load.
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

|||I'm also interested in this. Need to automate the build of our deployment package. Haven't been able to find any information on this.|||I am also interested in this topic .... Anyone can contribute any idea(s). Thanks.|||

hello,

i would expect something like the following to work

devenv.exe <your_solution_name>.sln /build Development /Out out.log

Note that you might need an SP1 build for this.

hope this helps,

building an .asdatabase file from the command line

Hi,

I was wondering if anyone knew how to 'build' an 'analysis services' project (i.e - generate the .asdatabase file) from the command line, so that I could have it done automatically during a build process.

Thanks,
Kobi Reiter

Play around with the devenv.exe executable at the command-line. Although I have not tried it, you might be able to use it with your project file and with a "/build" option. The executable is the what launches when you run BI Dev Studio. Typical setup has it located at:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Dave Fackler

|||

Unfortunately, when I try to run devenv with the /build switch, it fails:

Package 'Visual Studio Source Control Integration Package' failed to load.
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

|||I'm also interested in this. Need to automate the build of our deployment package. Haven't been able to find any information on this.
|||I am also interested in this topic .... Anyone can contribute any idea(s). Thanks.|||

hello,

i would expect something like the following to work

devenv.exe <your_solution_name>.sln /build Development /Out out.log

Note that you might need an SP1 build for this.

hope this helps,

Friday, February 10, 2012

build random phone number.

I'm building a test database and I need to randomly create phone numbers in the format xxxxxxxxxx

I have 5000 contacts and need to generate fake phone numbers for them. anyone know how I can write an update query to do this?

ScAndalThe way I can think to do this is:

1. create a View that will return a random number (this is needed because the RAND() function cannot be called from another function (the one we are creating in step 2 below))


CREATE VIEW dbo.vRandNumber
AS
SELECT RAND() AS RandomNumber

2. write a GenerateRandomNumber UDF:

CREATE FUNCTION GenerateRandomNumber(@.Min int, @.Max int)
RETURNS float
AS
BEGIN
RETURN @.Min + (select RandomNumber from vRandNumber) * (@.Max-@.Min)
END

3. write a GenerateRandomPhoneNumber UDF:

CREATE FUNCTION dbo.GenerateRandomPhoneNumber ()
RETURNS varchar(10) AS
BEGIN

DECLARE @.myNumber int, @.myPhoneNumber varchar(9), @.X smallint

SELECT @.X = 0, @.myPhoneNumber =''
WHILE @.X < 10
BEGIN
SELECT @.myNumber=dbo.generaterandomnumber(0,9)
SELECT @.myPhoneNumber = @.myPhoneNumber + CAST(@.myNumber AS CHAR(1))
SELECT @.X = @.X + 1
END

RETURN @.myPhoneNumber

END


4. populate the fake phone numbers like this:

UPDATE contacts SET PhoneNumber = GenerateRandomPhoneNumber()

This is just my first thought. Someone else might come along and do it in 2 steps ;-)
Terri|||I can do it in 1 step! Assuming that table has a identity column you can use it as a seed for the rand() function:


update Contact
set PhoneNumber = cast(cast(rand(ContactID * 12345)*90000 as int) + 10000 as varchar)
+ cast(cast(rand(ContactID * 54321)*90000 as int) + 10000 as varchar)

I had to do 5 digits at a time to avoid the int size problem, and I had to multiply the identity column with a largeish number to make the phone numbers look random.

For some reason
rand(X) - rand(X + 1) = -1.8633e-005
for all values of X

Just noticed it. Seems wrong to me. Ah well. Just don't use this to randomize lotto numbers and you'll be fine.|||Here is a variation of Terri's:

--create a view to expose NEWID() for randomness
create view dbo.vwRandomNumGenerator
as
select top 10 n
from
(
select 0 n union all
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 union all
select 9 union all
select 9
) d
order by newid()
go

--create udf
create function dbo.udfPhoneNumberGenerator ()
returns char(10)
AS
begin
declare @.phoneNumber char(10)
set @.phoneNumber = ''

Select @.phoneNumber = n + @.phoneNumber
from
(
select convert(char(1),n) n
from dbo.vwRandomNumGenerator

) d
return @.phoneNumber
end
go

--call our rnd phone generator inline
select dbo.udfPhoneNumberGenerator() RandomPhoneNumber

--drop view vwRandomNumGenerator
--drop function udfPhoneNumberGenerator

|||Thanks guys! That worked perfectly.

Great advice!

ScAndal