Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Friday, March 30, 2012

Scripting component.

Hi Guys,

I need to generate a file using script component. I'm taking some data from an oledb source and then i would need to modify the fields, generate new fields and then generate the flat file.

I don't have any problems with this but the file i need to replicate would need to have a head record and a trail record which doesn't need to be duplicated.

Now when i generate the file and put anything in "Public Overrides Sub Input0_ProcessInputRow" it will work but it will generate the header record again and again as well.

Any quick help would be really appreciated.


TA

Gemma

Gemma,

Any reason for using the script component to create the file? Can you just use the script to populate the pipeline and use a flat file destination for the file? If so, I recently described how you would go about creating a flat file with header and trailing records.. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2168163&SiteID=1

|||

Hi Eric,

I'm just combinging the fields, padding the fields with zero and doing some cleaning of the data as well.

Is there any other way? I've checked your post but I don't know how to add something from the database in the header.

Yes you can enter any expressions but i need the value from the table.

Can you help me do that?


TA
Gemma

|||

Add a boolean flag at the class level and default it to True, Then in the ProcessInput check the flag. If it is True, write the header line and change the flag to false.

There's an example of that approach in the script I posted here - http://agilebi.com/cs/blogs/jwelch/archive/2007/09/14/dynamically-pivoting-rows-to-columns.aspx. The example is not what you were asking about, but the script illustrates the technique.

Scripting a query to run daily.

I was just asked to script a Query that needs to run
daily and save the results as a file somewhere on the
network. The problem is that this report query needs to
be changed daily for example I need to run a report on
all scheduled apointments from the day before. My
question is this: Is there a system variable that I can
enter on the query that tells SQL to check the current
date on the system minus one so that the report is from
the day before (or Something similar). I have the query
and it runs as it should but I need to change the date
manually. If there's a solution to this problem please
let me know and how to insert it on the query.
Thanks.getDate() gets the current system date. There are some date-manipulation
functions, such as dateAdd() (or something similar). Check out BOL
"Carlos Santos" <anonymous@.discussions.microsoft.com> wrote in message
news:2b15e01c4682c$b05b9c20$a501280a@.phx
.gbl...
> I was just asked to script a Query that needs to run
> daily and save the results as a file somewhere on the
> network. The problem is that this report query needs to
> be changed daily for example I need to run a report on
> all scheduled apointments from the day before. My
> question is this: Is there a system variable that I can
> enter on the query that tells SQL to check the current
> date on the system minus one so that the report is from
> the day before (or Something similar). I have the query
> and it runs as it should but I need to change the date
> manually. If there's a solution to this problem please
> let me know and how to insert it on the query.
> Thanks.|||You need to look at DATEADD function. This function allows you to do
datemath to calculate a new date. Also you might want to look into the
CONVERT function to get the output of the DATEADD function into a format to
compare with your data. Here is a query that uses these function to get
yesterdays date in the following format mm/dd/yyyy:
select * from yourtable where yourdatecolumn =
convert(char(10),dateadd(dd,-1,getdate()),101)
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Carlos Santos" <anonymous@.discussions.microsoft.com> wrote in message
news:2b15e01c4682c$b05b9c20$a501280a@.phx
.gbl...
> I was just asked to script a Query that needs to run
> daily and save the results as a file somewhere on the
> network. The problem is that this report query needs to
> be changed daily for example I need to run a report on
> all scheduled apointments from the day before. My
> question is this: Is there a system variable that I can
> enter on the query that tells SQL to check the current
> date on the system minus one so that the report is from
> the day before (or Something similar). I have the query
> and it runs as it should but I need to change the date
> manually. If there's a solution to this problem please
> let me know and how to insert it on the query.
> Thanks.sql

Scripting a query to run daily.

I was just asked to script a Query that needs to run
daily and save the results as a file somewhere on the
network. The problem is that this report query needs to
be changed daily for example I need to run a report on
all scheduled apointments from the day before. My
question is this: Is there a system variable that I can
enter on the query that tells SQL to check the current
date on the system minus one so that the report is from
the day before (or Something similar). I have the query
and it runs as it should but I need to change the date
manually. If there's a solution to this problem please
let me know and how to insert it on the query.
Thanks.
getDate() gets the current system date. There are some date-manipulation
functions, such as dateAdd() (or something similar). Check out BOL
"Carlos Santos" <anonymous@.discussions.microsoft.com> wrote in message
news:2b15e01c4682c$b05b9c20$a501280a@.phx.gbl...
> I was just asked to script a Query that needs to run
> daily and save the results as a file somewhere on the
> network. The problem is that this report query needs to
> be changed daily for example I need to run a report on
> all scheduled apointments from the day before. My
> question is this: Is there a system variable that I can
> enter on the query that tells SQL to check the current
> date on the system minus one so that the report is from
> the day before (or Something similar). I have the query
> and it runs as it should but I need to change the date
> manually. If there's a solution to this problem please
> let me know and how to insert it on the query.
> Thanks.
|||You need to look at DATEADD function. This function allows you to do
datemath to calculate a new date. Also you might want to look into the
CONVERT function to get the output of the DATEADD function into a format to
compare with your data. Here is a query that uses these function to get
yesterdays date in the following format mm/dd/yyyy:
select * from yourtable where yourdatecolumn =
convert(char(10),dateadd(dd,-1,getdate()),101)
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Carlos Santos" <anonymous@.discussions.microsoft.com> wrote in message
news:2b15e01c4682c$b05b9c20$a501280a@.phx.gbl...
> I was just asked to script a Query that needs to run
> daily and save the results as a file somewhere on the
> network. The problem is that this report query needs to
> be changed daily for example I need to run a report on
> all scheduled apointments from the day before. My
> question is this: Is there a system variable that I can
> enter on the query that tells SQL to check the current
> date on the system minus one so that the report is from
> the day before (or Something similar). I have the query
> and it runs as it should but I need to change the date
> manually. If there's a solution to this problem please
> let me know and how to insert it on the query.
> Thanks.

Scripting a query to run daily.

I was just asked to script a Query that needs to run
daily and save the results as a file somewhere on the
network. The problem is that this report query needs to
be changed daily for example I need to run a report on
all scheduled apointments from the day before. My
question is this: Is there a system variable that I can
enter on the query that tells SQL to check the current
date on the system minus one so that the report is from
the day before (or Something similar). I have the query
and it runs as it should but I need to change the date
manually. If there's a solution to this problem please
let me know and how to insert it on the query.
Thanks.getDate() gets the current system date. There are some date-manipulation
functions, such as dateAdd() (or something similar). Check out BOL
"Carlos Santos" <anonymous@.discussions.microsoft.com> wrote in message
news:2b15e01c4682c$b05b9c20$a501280a@.phx.gbl...
> I was just asked to script a Query that needs to run
> daily and save the results as a file somewhere on the
> network. The problem is that this report query needs to
> be changed daily for example I need to run a report on
> all scheduled apointments from the day before. My
> question is this: Is there a system variable that I can
> enter on the query that tells SQL to check the current
> date on the system minus one so that the report is from
> the day before (or Something similar). I have the query
> and it runs as it should but I need to change the date
> manually. If there's a solution to this problem please
> let me know and how to insert it on the query.
> Thanks.|||You need to look at DATEADD function. This function allows you to do
datemath to calculate a new date. Also you might want to look into the
CONVERT function to get the output of the DATEADD function into a format to
compare with your data. Here is a query that uses these function to get
yesterdays date in the following format mm/dd/yyyy:
select * from yourtable where yourdatecolumn =convert(char(10),dateadd(dd,-1,getdate()),101)
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Carlos Santos" <anonymous@.discussions.microsoft.com> wrote in message
news:2b15e01c4682c$b05b9c20$a501280a@.phx.gbl...
> I was just asked to script a Query that needs to run
> daily and save the results as a file somewhere on the
> network. The problem is that this report query needs to
> be changed daily for example I need to run a report on
> all scheduled apointments from the day before. My
> question is this: Is there a system variable that I can
> enter on the query that tells SQL to check the current
> date on the system minus one so that the report is from
> the day before (or Something similar). I have the query
> and it runs as it should but I need to change the date
> manually. If there's a solution to this problem please
> let me know and how to insert it on the query.
> Thanks.

Wednesday, March 21, 2012

Script Task working in Visual Studio but not when the package is run by a job?

I have a script that changes the name of a file after a data upload. The script works fine if I execute the package in Visual Studio but when I run the file package from a SQL server job it does not rename the file. The data does get uploaded it just does not run the final script.

Any help would be appreciated.

Steve

Have you enabled logging to get the error?

The problems when running under Agent are mostly related to authentication and permissions issues - as the job probably runs under different credentials compared to interactive execution. Your options are either configure job to run under your account, or fix the permissions to allow job account to perform the operation that is failing.

See this KB for troubleshooting steps:
http://support.microsoft.com/kb/918760

Script Task - Am I leaving any resources open?

I've got a service that waits for a file to drop and then calls a ssis package that then gets a date from the first line of the file, sets it to a variable, then imports the rest of the file using the flat file import through a data flow task.

Occasionally the script task fails with this error message:

The script threw an exception: Access to the path 'C:\path\flatfile.txt' is denied.

Here is the code of my script:

Public Sub Main()
'
' Add your code here
'
Dim vars As Variables
Dts.VariableDispenser.LockOneForRead("User::FullFilePath", vars)

Dim filepath As String = vars("FullFilePath").Value.ToString()

vars.Unlock()

Dim file As File
Dim reader As StreamReader

reader = file.OpenText(filepath)

Dim line As String
line = reader.ReadLine()

reader.Close()

'MsgBox(line.Substring(29))

Dim asofdate As String
asofdate = line.Substring(29, 5)
asofdate = asofdate + "20" + line.Substring(34)

'MsgBox(asofdate)

Dim writeVars As Variables
Dts.VariableDispenser.LockOneForWrite("User::AsOfDate", writeVars)
writeVars(0).Value = asofdate

'MsgBox("done")

writeVars.Unlock()

Dts.TaskResult = Dts.Results.Success
End Sub

Does anyone see anything that I'm not. I believe i'm closing all necessary resources and streams. Does anyone have suggestions.

Thank you very much in advance.

Is it possible that your service calls the package multiple times simultaneously, or that the package could be executed before the drop is completed? The access violation in either of those cases would be due to the file still being locked by something else (e.g. the process writing the file, or the first package processing the file).

If neither are the case, then you could try a small re-write to see if it helps:

Replace:

Dim file As File
Dim reader As StreamReader

reader = file.OpenText(filepath)

Dim line As String
line = reader.ReadLine()

reader.Close()

With:

Dim line As String

Using reader as new StreamReader(filepath)

line = reader.Readline()

reader.Close()

End Using

HTH,

Patrik

|||Thanks for your response.

After banging my head against the table for a day i realized that the reason I was having issues is because the package in question was running as a service. The service was running under a particular user or usergroup. This usergroup was not one that had access to the files being run through my package, and therefore the package had its access deined by the OS.

In the interest of helping others, I'll leave this post up, even though it should have been one of the first things I tried.

Script Syntax Errors

i have new server, win2003, sql2005. trying to restore a .bak file from
sql2000. when excuting the RESTORE DATABASE dbase1 from
disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
displayed.
Executing the query ...
Query (1, 9) Parser: The syntax for 'database' is incorrect.
Execution complete
any ideas?
thanks in advance.
paulWhere do you execute this restore command? The error seems like some client application error...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>i have new server, win2003, sql2005. trying to restore a .bak file from
> sql2000. when excuting the RESTORE DATABASE dbase1 from
> disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> displayed.
> Executing the query ...
> Query (1, 9) Parser: The syntax for 'database' is incorrect.
> Execution complete
> any ideas?
> thanks in advance.
> paul|||i'm in the server management studio, right click on the database, new query,
mdx.
thanks.
paul
"Tibor Karaszi" wrote:
> Where do you execute this restore command? The error seems like some client application error...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >i have new server, win2003, sql2005. trying to restore a .bak file from
> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> > displayed.
> >
> > Executing the query ...
> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> > Execution complete
> >
> > any ideas?
> > thanks in advance.
> > paul
>|||mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
command.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> i'm in the server management studio, right click on the database, new query,
> mdx.
> thanks.
> paul
> "Tibor Karaszi" wrote:
>> Where do you execute this restore command? The error seems like some client application error...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "paul" <paul@.discussions.microsoft.com> wrote in message
>> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>> >i have new server, win2003, sql2005. trying to restore a .bak file from
>> > sql2000. when excuting the RESTORE DATABASE dbase1 from
>> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
>> > displayed.
>> >
>> > Executing the query ...
>> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
>> > Execution complete
>> >
>> > any ideas?
>> > thanks in advance.
>> > paul
>>|||oops, you are correct.
thanks.
when i try to connect to Database Engines a connection error is displayed;
name pipes provider error 40 and ms sql server error 53
"Tibor Karaszi" wrote:
> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
> command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> > i'm in the server management studio, right click on the database, new query,
> > mdx.
> > thanks.
> > paul
> >
> > "Tibor Karaszi" wrote:
> >
> >> Where do you execute this restore command? The error seems like some client application error...
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://sqlblog.com/blogs/tibor_karaszi
> >>
> >>
> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> >> > displayed.
> >> >
> >> > Executing the query ...
> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> >> > Execution complete
> >> >
> >> > any ideas?
> >> > thanks in advance.
> >> > paul
> >>
> >>
>|||Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
> oops, you are correct.
> thanks.
> when i try to connect to Database Engines a connection error is displayed;
> name pipes provider error 40 and ms sql server error 53
>
> "Tibor Karaszi" wrote:
>> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
>> command.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "paul" <paul@.discussions.microsoft.com> wrote in message
>> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
>> > i'm in the server management studio, right click on the database, new query,
>> > mdx.
>> > thanks.
>> > paul
>> >
>> > "Tibor Karaszi" wrote:
>> >
>> >> Where do you execute this restore command? The error seems like some client application
>> >> error...
>> >>
>> >> --
>> >> Tibor Karaszi, SQL Server MVP
>> >> http://www.karaszi.com/sqlserver/default.asp
>> >> http://sqlblog.com/blogs/tibor_karaszi
>> >>
>> >>
>> >> "paul" <paul@.discussions.microsoft.com> wrote in message
>> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
>> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
>> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
>> >> > displayed.
>> >> >
>> >> > Executing the query ...
>> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
>> >> > Execution complete
>> >> >
>> >> > any ideas?
>> >> > thanks in advance.
>> >> > paul
>> >>
>> >>
>>|||in SQL Server Config Manager there are 3 items listed; Service, Network
Config, Client Config.
in Services all are running; Integration,Analysis,Reporting, and Browser
in Network Config there are no items listed
in Client config, Protocols, all are running; Shared, NamePipes, TCP/IP, and
VIA
thanks.
paul
"Tibor Karaszi" wrote:
> Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
> > oops, you are correct.
> > thanks.
> >
> > when i try to connect to Database Engines a connection error is displayed;
> > name pipes provider error 40 and ms sql server error 53
> >
> >
> >
> > "Tibor Karaszi" wrote:
> >
> >> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL Server
> >> command.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://sqlblog.com/blogs/tibor_karaszi
> >>
> >>
> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> >> > i'm in the server management studio, right click on the database, new query,
> >> > mdx.
> >> > thanks.
> >> > paul
> >> >
> >> > "Tibor Karaszi" wrote:
> >> >
> >> >> Where do you execute this restore command? The error seems like some client application
> >> >> error...
> >> >>
> >> >> --
> >> >> Tibor Karaszi, SQL Server MVP
> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> http://sqlblog.com/blogs/tibor_karaszi
> >> >>
> >> >>
> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
> >> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> >> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> >> >> > displayed.
> >> >> >
> >> >> > Executing the query ...
> >> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> >> >> > Execution complete
> >> >> >
> >> >> > any ideas?
> >> >> > thanks in advance.
> >> >> > paul
> >> >>
> >> >>
> >>
> >>
>|||Seems you didn't install SQL Server:
> in Services all are running; Integration,Analysis,Reporting, and Browser
If you had installed SQL Server, you would have also a "SQL Server" service.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"paul" <paul@.discussions.microsoft.com> wrote in message
news:BFEF1B78-052E-4EB1-8A9A-D3804256436C@.microsoft.com...
> in SQL Server Config Manager there are 3 items listed; Service, Network
> Config, Client Config.
> in Services all are running; Integration,Analysis,Reporting, and Browser
> in Network Config there are no items listed
> in Client config, Protocols, all are running; Shared, NamePipes, TCP/IP, and
> VIA
> thanks.
> paul
> "Tibor Karaszi" wrote:
>> Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "paul" <paul@.discussions.microsoft.com> wrote in message
>> news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
>> > oops, you are correct.
>> > thanks.
>> >
>> > when i try to connect to Database Engines a connection error is displayed;
>> > name pipes provider error 40 and ms sql server error 53
>> >
>> >
>> >
>> > "Tibor Karaszi" wrote:
>> >
>> >> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL
>> >> Server
>> >> command.
>> >>
>> >> --
>> >> Tibor Karaszi, SQL Server MVP
>> >> http://www.karaszi.com/sqlserver/default.asp
>> >> http://sqlblog.com/blogs/tibor_karaszi
>> >>
>> >>
>> >> "paul" <paul@.discussions.microsoft.com> wrote in message
>> >> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
>> >> > i'm in the server management studio, right click on the database, new query,
>> >> > mdx.
>> >> > thanks.
>> >> > paul
>> >> >
>> >> > "Tibor Karaszi" wrote:
>> >> >
>> >> >> Where do you execute this restore command? The error seems like some client application
>> >> >> error...
>> >> >>
>> >> >> --
>> >> >> Tibor Karaszi, SQL Server MVP
>> >> >> http://www.karaszi.com/sqlserver/default.asp
>> >> >> http://sqlblog.com/blogs/tibor_karaszi
>> >> >>
>> >> >>
>> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
>> >> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
>> >> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
>> >> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
>> >> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
>> >> >> > displayed.
>> >> >> >
>> >> >> > Executing the query ...
>> >> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
>> >> >> > Execution complete
>> >> >> >
>> >> >> > any ideas?
>> >> >> > thanks in advance.
>> >> >> > paul
>> >> >>
>> >> >>
>> >>
>> >>
>>|||i'm an idiot.
thanks.
paul
"Tibor Karaszi" wrote:
> Seems you didn't install SQL Server:
> > in Services all are running; Integration,Analysis,Reporting, and Browser
> If you had installed SQL Server, you would have also a "SQL Server" service.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "paul" <paul@.discussions.microsoft.com> wrote in message
> news:BFEF1B78-052E-4EB1-8A9A-D3804256436C@.microsoft.com...
> > in SQL Server Config Manager there are 3 items listed; Service, Network
> > Config, Client Config.
> >
> > in Services all are running; Integration,Analysis,Reporting, and Browser
> > in Network Config there are no items listed
> > in Client config, Protocols, all are running; Shared, NamePipes, TCP/IP, and
> > VIA
> >
> > thanks.
> > paul
> >
> > "Tibor Karaszi" wrote:
> >
> >> Make sure the server is listening on appropriate netlibs (SQL Server Configuration Manager).
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://sqlblog.com/blogs/tibor_karaszi
> >>
> >>
> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> news:7FB8AAE2-17F5-4BCB-9E53-CBF44547A053@.microsoft.com...
> >> > oops, you are correct.
> >> > thanks.
> >> >
> >> > when i try to connect to Database Engines a connection error is displayed;
> >> > name pipes provider error 40 and ms sql server error 53
> >> >
> >> >
> >> >
> >> > "Tibor Karaszi" wrote:
> >> >
> >> >> mdx? Seems you have connected to Analysis server. The restore command you posted is a SQL
> >> >> Server
> >> >> command.
> >> >>
> >> >> --
> >> >> Tibor Karaszi, SQL Server MVP
> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> http://sqlblog.com/blogs/tibor_karaszi
> >> >>
> >> >>
> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> >> news:13EB6139-0A6A-4F67-9F6F-12B430BE9DC3@.microsoft.com...
> >> >> > i'm in the server management studio, right click on the database, new query,
> >> >> > mdx.
> >> >> > thanks.
> >> >> > paul
> >> >> >
> >> >> > "Tibor Karaszi" wrote:
> >> >> >
> >> >> >> Where do you execute this restore command? The error seems like some client application
> >> >> >> error...
> >> >> >>
> >> >> >> --
> >> >> >> Tibor Karaszi, SQL Server MVP
> >> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> >> http://sqlblog.com/blogs/tibor_karaszi
> >> >> >>
> >> >> >>
> >> >> >> "paul" <paul@.discussions.microsoft.com> wrote in message
> >> >> >> news:2DBA2DA0-FEE5-481A-AF28-E1D9558BFE05@.microsoft.com...
> >> >> >> >i have new server, win2003, sql2005. trying to restore a .bak file from
> >> >> >> > sql2000. when excuting the RESTORE DATABASE dbase1 from
> >> >> >> > disk='c:\dbasebackup.bak' command, or using FILELISTONLY, the error below is
> >> >> >> > displayed.
> >> >> >> >
> >> >> >> > Executing the query ...
> >> >> >> > Query (1, 9) Parser: The syntax for 'database' is incorrect.
> >> >> >> > Execution complete
> >> >> >> >
> >> >> >> > any ideas?
> >> >> >> > thanks in advance.
> >> >> >> > paul
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >>
> >>
>

Monday, March 12, 2012

script in text in 2005 EM?

Hi,

In 2000 you could script out a file (tables SP's etc.) as text by going under Options -> File Options and choosing the MS-DOS text (OEM) format. I'm wondering where/if this same capability is in 2005. Right now, it looks like the default is binary. Can anybody share some information on this?

Thanks,

Phil

Using SSMS, in the Object Explorer, right click on the database, table, Progamable object, etc., and select [Script ... as]|||

That's only how to script an object. My question is how to script an object as text. If you notice when you script an object like the way you are suggesting, it will by a binary file (atleast when I check it into sourcesafe). This was an issue I had before in SQL 2000, but atleast it gave the option to script the file out to MS DOS (text). Does anyone else know what I'm referring to?

Thanks,

Phil

script in MSDE

Hi,
i have msde on my system and i running my queries though osql utility
can any one tell me how can i run a script file in osql i.e in my C:
drive
what cmd i have to type
Thanks,
Use the /i switch for OSQL.EXE.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Abhi" <bawejaji@.gmail.com> wrote in message
news:1181204598.353419.105710@.k79g2000hse.googlegr oups.com...
> Hi,
> i have msde on my system and i running my queries though osql utility
> can any one tell me how can i run a script file in osql i.e in my C:
> drive
> what cmd i have to type
> Thanks,
>
|||On Jun 7, 2:59 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:[vbcol=seagreen]
> Use the /i switch for OSQL.EXE.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "Abhi" <bawej...@.gmail.com> wrote in message
> news:1181204598.353419.105710@.k79g2000hse.googlegr oups.com...
>
right now I am in osql utility but still i am not able to run the
script i.e on c:\folder
Please advice...
|||So you want to call a script while *inside* OSQL? If so, check out the :r option.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Abhi" <bawejaji@.gmail.com> wrote in message
news:1181212829.895541.324540@.n15g2000prd.googlegr oups.com...
> On Jun 7, 2:59 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> right now I am in osql utility but still i am not able to run the
> script i.e on c:\folder
> Please advice...
>
|||On Jun 7, 3:53 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:[vbcol=seagreen]
> So you want to call a script while *inside* OSQL? If so, check out the :r option.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "Abhi" <bawej...@.gmail.com> wrote in message
> news:1181212829.895541.324540@.n15g2000prd.googlegr oups.com...
>
>
>
>
Many Thanks, Sir it's working in osql

script in MSDE

Hi,
i have msde on my system and i running my queries though osql utility
can any one tell me how can i run a script file in osql i.e in my C:
drive
what cmd i have to type
Thanks,Use the /i switch for OSQL.EXE.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Abhi" <bawejaji@.gmail.com> wrote in message
news:1181204598.353419.105710@.k79g2000hse.googlegroups.com...
> Hi,
> i have msde on my system and i running my queries though osql utility
> can any one tell me how can i run a script file in osql i.e in my C:
> drive
> what cmd i have to type
> Thanks,
>|||On Jun 7, 2:59 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> Use the /i switch for OSQL.EXE.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "Abhi" <bawej...@.gmail.com> wrote in message
> news:1181204598.353419.105710@.k79g2000hse.googlegroups.com...
> > Hi,
> > i have msde on my system and i running my queries though osql utility
> > can any one tell me how can i run a script file in osql i.e in my C:
> > drive
> > what cmd i have to type
> > Thanks,
right now I am in osql utility but still i am not able to run the
script i.e on c:\folder
Please advice...|||So you want to call a script while *inside* OSQL? If so, check out the :r option.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Abhi" <bawejaji@.gmail.com> wrote in message
news:1181212829.895541.324540@.n15g2000prd.googlegroups.com...
> On Jun 7, 2:59 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
>> Use the /i switch for OSQL.EXE.
>> --
>> Tibor Karaszi, SQL Server
>> MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
>> "Abhi" <bawej...@.gmail.com> wrote in message
>> news:1181204598.353419.105710@.k79g2000hse.googlegroups.com...
>> > Hi,
>> > i have msde on my system and i running my queries though osql utility
>> > can any one tell me how can i run a script file in osql i.e in my C:
>> > drive
>> > what cmd i have to type
>> > Thanks,
> right now I am in osql utility but still i am not able to run the
> script i.e on c:\folder
> Please advice...
>|||On Jun 7, 3:53 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> So you want to call a script while *inside* OSQL? If so, check out the :r option.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "Abhi" <bawej...@.gmail.com> wrote in message
> news:1181212829.895541.324540@.n15g2000prd.googlegroups.com...
> > On Jun 7, 2:59 pm, "Tibor Karaszi"
> > <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> >> Use the /i switch for OSQL.EXE.
> >> --
> >> Tibor Karaszi, SQL Server
> >> MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/...
> >> "Abhi" <bawej...@.gmail.com> wrote in message
> >>news:1181204598.353419.105710@.k79g2000hse.googlegroups.com...
> >> > Hi,
> >> > i have msde on my system and i running my queries though osql utility
> >> > can any one tell me how can i run a script file in osql i.e in my C:
> >> > drive
> >> > what cmd i have to type
> >> > Thanks,
> > right now I am in osql utility but still i am not able to run the
> > script i.e on c:\folder
> > Please advice...
Many Thanks, Sir it's working in osql

script in MSDE

Hi,
i have msde on my system and i running my queries though osql utility
can any one tell me how can i run a script file in osql i.e in my C:
drive
what cmd i have to type
Thanks,Use the /i switch for OSQL.EXE.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Abhi" <bawejaji@.gmail.com> wrote in message
news:1181204598.353419.105710@.k79g2000hse.googlegroups.com...
> Hi,
> i have msde on my system and i running my queries though osql utility
> can any one tell me how can i run a script file in osql i.e in my C:
> drive
> what cmd i have to type
> Thanks,
>|||On Jun 7, 2:59 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:[vbcol=seagreen]
> Use the /i switch for OSQL.EXE.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asph
ttp://sqlblog.com/blogs/tibor_karaszi
> "Abhi" <bawej...@.gmail.com> wrote in message
> news:1181204598.353419.105710@.k79g2000hse.googlegroups.com...
>
>
>
right now I am in osql utility but still i am not able to run the
script i.e on c:\folder
Please advice...|||So you want to call a script while *inside* OSQL? If so, check out the :r op
tion.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Abhi" <bawejaji@.gmail.com> wrote in message
news:1181212829.895541.324540@.n15g2000prd.googlegroups.com...
> On Jun 7, 2:59 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> right now I am in osql utility but still i am not able to run the
> script i.e on c:\folder
> Please advice...
>|||On Jun 7, 3:53 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:[vbcol=seagreen]
> So you want to call a script while *inside* OSQL? If so, check out the :r
option.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asph
ttp://sqlblog.com/blogs/tibor_karaszi
> "Abhi" <bawej...@.gmail.com> wrote in message
> news:1181212829.895541.324540@.n15g2000prd.googlegroups.com...
>
>
>
>
>
>
>
>
Many Thanks, Sir it's working in osql

Script Help

Would really appreciate some help/ideas. The stored procedures for my
application are all saved to a folder in the file system of my deeloper work
station. What is the best way to loop through the folder and execute the sql
(create procedure...)in each file?
Thanks for any tipsOne method is to run your scripts with a FOR command from the command-prompt
that invokes OSQL. For example:
FOR %f IN (*.SQL) DO OSQL -i "%f" /E /S MyServer
Hope this helps.
Dan Guzman
SQL Server MVP
"Mardy" <Mardy@.discussions.microsoft.com> wrote in message
news:F9E35C8D-A44A-484A-A63B-D3571A908AF8@.microsoft.com...
> Would really appreciate some help/ideas. The stored procedures for my
> application are all saved to a folder in the file system of my deeloper
> work
> station. What is the best way to loop through the folder and execute the
> sql
> (create procedure...)in each file?
> Thanks for any tips|||FYI, I generally just copy all of the procedures to one file and run that:
COPY *.* SP.sql
But this will only work if you have a GO statement at the bottom of each.
"Dan Guzman" wrote:

> One method is to run your scripts with a FOR command from the command-prom
pt
> that invokes OSQL. For example:
> FOR %f IN (*.SQL) DO OSQL -i "%f" /E /S MyServer
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Mardy" <Mardy@.discussions.microsoft.com> wrote in message
> news:F9E35C8D-A44A-484A-A63B-D3571A908AF8@.microsoft.com...
>
>

Script for Posting RDLs

Hi there,
There are times when i post up to 100 rdls on to the report server. But this
process is long drawn as you can only upload 1 file at a time from the
reportserver.
I've heard of people here talking of a script to deploy reports which makes
it a hell of alot quicker than uploading manually.
Firstly, what is the script, and secondly where do you execute it(is it on
the same platform as where Reports are coded?)
Thanks in Advance
SanjeevHi Sanjeev,
Use the rs.exe command line utility
see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsamples/htm/rss_sampleapps_v1_8l42.asp
see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_prog_soapapi_script_61gi.asp
regards,
- peteZ
"Sanjeev" <sanjeev@.microsoft.com> wrote in message
news:%23yCjXMQsEHA.2788@.TK2MSFTNGP09.phx.gbl...
> Hi there,
> There are times when i post up to 100 rdls on to the report server. But
> this process is long drawn as you can only upload 1 file at a time from
> the reportserver.
> I've heard of people here talking of a script to deploy reports which
> makes it a hell of alot quicker than uploading manually.
> Firstly, what is the script, and secondly where do you execute it(is it on
> the same platform as where Reports are coded?)
> Thanks in Advance
> Sanjeev
>|||Hi,
I am getting somewhere now.
But i am still experiencing a problem. When i run the command to publish my
RDLs it says that the corresponding *.rss script cannot be found. Do you
know how to install these .rss scripts onto the hard-drive.
Sorry for bugging
Thanks PeteZ
Sanjeev
"PeteZ" <peteZ@.aol.com> wrote in message
news:e0OAiVQsEHA.376@.TK2MSFTNGP09.phx.gbl...
> Hi Sanjeev,
> Use the rs.exe command line utility
> see:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsamples/htm/rss_sampleapps_v1_8l42.asp
> see:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_prog_soapapi_script_61gi.asp
> regards,
> - peteZ
>
> "Sanjeev" <sanjeev@.microsoft.com> wrote in message
> news:%23yCjXMQsEHA.2788@.TK2MSFTNGP09.phx.gbl...
>> Hi there,
>> There are times when i post up to 100 rdls on to the report server. But
>> this process is long drawn as you can only upload 1 file at a time from
>> the reportserver.
>> I've heard of people here talking of a script to deploy reports which
>> makes it a hell of alot quicker than uploading manually.
>> Firstly, what is the script, and secondly where do you execute it(is it
>> on the same platform as where Reports are coded?)
>> Thanks in Advance
>> Sanjeev
>

Script for moving a file to a different folder

Hi All,
Is there a script(.rss file) that can move a .rdl file to a different folder
than the one in which it is in.
eg. Assume File is on The "Reports" folder in the Report Server. Now I wish
to move it into the "Reports\Vehicles" folder. Is there a script that can
facilitate this rather than doing it manually.
Regards
SanjeevIt could be done easily using MoveItem call.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Sanjeev" <sanjeev@.microsoft.com> wrote in message
news:O%23ATGnbtEHA.2804@.TK2MSFTNGP14.phx.gbl...
> Hi All,
> Is there a script(.rss file) that can move a .rdl file to a different
> folder than the one in which it is in.
> eg. Assume File is on The "Reports" folder in the Report Server. Now I
> wish to move it into the "Reports\Vehicles" folder. Is there a script that
> can facilitate this rather than doing it manually.
> Regards
> Sanjeev
>|||Thanks. That worked perfectly.
"Lev Semenets [MSFT]" <levs@.microsoft.com> wrote in message
news:OBwnvZmtEHA.2600@.TK2MSFTNGP10.phx.gbl...
> It could be done easily using MoveItem call.
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "Sanjeev" <sanjeev@.microsoft.com> wrote in message
> news:O%23ATGnbtEHA.2804@.TK2MSFTNGP14.phx.gbl...
>> Hi All,
>> Is there a script(.rss file) that can move a .rdl file to a different
>> folder than the one in which it is in.
>> eg. Assume File is on The "Reports" folder in the Report Server. Now I
>> wish to move it into the "Reports\Vehicles" folder. Is there a script
>> that can facilitate this rather than doing it manually.
>> Regards
>> Sanjeev
>

script for generating service user account?

Hi,
Is there a script available to create the sql server service account and set
the file system and registry permissions correctly? I would like to run my
server with minimum access rights and I would like to save some time if
someone has done a nice script for creating the account and/or setting the
permissions in a way that it can easily be reused.
Svenhave a look at this
http://support.microsoft.com/kb/283811/en-us
this details what you need to script.
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Matzen" <Matzen@.discussions.microsoft.com> wrote in message
news:AA0493D1-A1F6-43F3-9D34-4A590FD410F8@.microsoft.com...
> Hi,
> Is there a script available to create the sql server service account and
> set
> the file system and registry permissions correctly? I would like to run my
> server with minimum access rights and I would like to save some time if
> someone has done a nice script for creating the account and/or setting the
> permissions in a way that it can easily be reused.
> Sven

script for generating service user account?

Hi,
Is there a script available to create the sql server service account and set
the file system and registry permissions correctly? I would like to run my
server with minimum access rights and I would like to save some time if
someone has done a nice script for creating the account and/or setting the
permissions in a way that it can easily be reused.
Svenhave a look at this
http://support.microsoft.com/kb/283811/en-us
this details what you need to script.
--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Matzen" <Matzen@.discussions.microsoft.com> wrote in message
news:AA0493D1-A1F6-43F3-9D34-4A590FD410F8@.microsoft.com...
> Hi,
> Is there a script available to create the sql server service account and
> set
> the file system and registry permissions correctly? I would like to run my
> server with minimum access rights and I would like to save some time if
> someone has done a nice script for creating the account and/or setting the
> permissions in a way that it can easily be reused.
> Sven

Friday, March 9, 2012

Script for Adding Users after Restore?

When I backup a database to a single file in SQL2K, then restore that
database onto another machine, I lose users I have created (and I understand
that is expected behavior). Then I manually remove the name of the user
under "Name" since it doesn't have a "Login Name" and then just add this
same user as a New user and both the Name and Login Name appear and
everything is fine.
Is there a way to script this using SQL so if someone unfamiliar with EM
could simply run a script?This happens only with SQL Server authentication, not with Windows
authentication. So the first recommendation to avoid this problem is to use
Windows authentication.
In both cases, the login must exist on the new server.
For SQL Server authentication only use the sp_change_users_login to update
the link between logins and users of a database. For example,
sp_change_users_login 'auto_fix', myuser
Hope this helps,
Ben Nevarez, MCDBA, OCP
Database Administrator
"Don Miller" wrote:

> When I backup a database to a single file in SQL2K, then restore that
> database onto another machine, I lose users I have created (and I understa
nd
> that is expected behavior). Then I manually remove the name of the user
> under "Name" since it doesn't have a "Login Name" and then just add this
> same user as a New user and both the Name and Login Name appear and
> everything is fine.
> Is there a way to script this using SQL so if someone unfamiliar with EM
> could simply run a script?
>
>|||Hope this helps!
http://support.microsoft.com/kb/246133/|||Thanks.
"Don Miller" <nospam@.nospam.com> wrote in message
news:e5$tB1scGHA.3888@.TK2MSFTNGP02.phx.gbl...
> When I backup a database to a single file in SQL2K, then restore that
> database onto another machine, I lose users I have created (and I
understand
> that is expected behavior). Then I manually remove the name of the user
> under "Name" since it doesn't have a "Login Name" and then just add this
> same user as a New user and both the Name and Login Name appear and
> everything is fine.
> Is there a way to script this using SQL so if someone unfamiliar with EM
> could simply run a script?
>

Script for Adding Users after Restore?

When I backup a database to a single file in SQL2K, then restore that
database onto another machine, I lose users I have created (and I understand
that is expected behavior). Then I manually remove the name of the user
under "Name" since it doesn't have a "Login Name" and then just add this
same user as a New user and both the Name and Login Name appear and
everything is fine.
Is there a way to script this using SQL so if someone unfamiliar with EM
could simply run a script?Hope this helps!
http://support.microsoft.com/kb/246133/|||This happens only with SQL Server authentication, not with Windows
authentication. So the first recommendation to avoid this problem is to use
Windows authentication.
In both cases, the login must exist on the new server.
For SQL Server authentication only use the sp_change_users_login to update
the link between logins and users of a database. For example,
sp_change_users_login 'auto_fix', myuser
Hope this helps,
Ben Nevarez, MCDBA, OCP
Database Administrator
"Don Miller" wrote:
> When I backup a database to a single file in SQL2K, then restore that
> database onto another machine, I lose users I have created (and I understand
> that is expected behavior). Then I manually remove the name of the user
> under "Name" since it doesn't have a "Login Name" and then just add this
> same user as a New user and both the Name and Login Name appear and
> everything is fine.
> Is there a way to script this using SQL so if someone unfamiliar with EM
> could simply run a script?
>
>|||Thanks.
"Don Miller" <nospam@.nospam.com> wrote in message
news:e5$tB1scGHA.3888@.TK2MSFTNGP02.phx.gbl...
> When I backup a database to a single file in SQL2K, then restore that
> database onto another machine, I lose users I have created (and I
understand
> that is expected behavior). Then I manually remove the name of the user
> under "Name" since it doesn't have a "Login Name" and then just add this
> same user as a New user and both the Name and Login Name appear and
> everything is fine.
> Is there a way to script this using SQL so if someone unfamiliar with EM
> could simply run a script?
>

script file from stored procedure

Hi
Can anybody tell me how I call a sql script file(or any file for that
matter) from within a stored procedure? e.g. file on c:\filename.sql
I want the procedure to retrieve the file and also to run it.
Thanks in advance
The simplest way to do this is using xp_cmdshell to call ISQL or OSQL.
There is no direct TSQL command that allows you to run a script stored in a
file.

Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"jonjo" <jonjo@.discussions.microsoft.com> wrote in message
news:21A98D8B-C58A-46E3-B8A4-D6D115AE9744@.microsoft.com...
> Hi
> Can anybody tell me how I call a sql script file(or any file for that
> matter) from within a stored procedure? e.g. file on c:\filename.sql
> I want the procedure to retrieve the file and also to run it.
> Thanks in advance
|||You can use xp_cmdshell and oSql to do this.
Andrew J. Kelly SQL MVP
"jonjo" <jonjo@.discussions.microsoft.com> wrote in message
news:21A98D8B-C58A-46E3-B8A4-D6D115AE9744@.microsoft.com...
> Hi
> Can anybody tell me how I call a sql script file(or any file for that
> matter) from within a stored procedure? e.g. file on c:\filename.sql
> I want the procedure to retrieve the file and also to run it.
> Thanks in advance

script file from stored procedure

Hi
Can anybody tell me how I call a sql script file(or any file for that
matter) from within a stored procedure? e.g. file on c:\filename.sql
I want the procedure to retrieve the file and also to run it.
Thanks in advanceThe simplest way to do this is using xp_cmdshell to call ISQL or OSQL.
There is no direct TSQL command that allows you to run a script stored in a
file.
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"jonjo" <jonjo@.discussions.microsoft.com> wrote in message
news:21A98D8B-C58A-46E3-B8A4-D6D115AE9744@.microsoft.com...
> Hi
> Can anybody tell me how I call a sql script file(or any file for that
> matter) from within a stored procedure? e.g. file on c:\filename.sql
> I want the procedure to retrieve the file and also to run it.
> Thanks in advance|||You can use xp_cmdshell and oSql to do this.
Andrew J. Kelly SQL MVP
"jonjo" <jonjo@.discussions.microsoft.com> wrote in message
news:21A98D8B-C58A-46E3-B8A4-D6D115AE9744@.microsoft.com...
> Hi
> Can anybody tell me how I call a sql script file(or any file for that
> matter) from within a stored procedure? e.g. file on c:\filename.sql
> I want the procedure to retrieve the file and also to run it.
> Thanks in advance