Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Thursday, March 29, 2012

Get Analysis Services Version string in c#.net 2.0

Hi

I want to get the version string for AS 2000 and 2005 in c#. Can I use the same object model to connect to both or do I need one for each. I saw a reference to DSO 8.5 which implied you could.

Either way could you let me know what DDL I should reference in Visual Studio.

Thanks

Steve

If you are using Microsoft.AnalysisServices.AdomdClient then you can use AdomdConnection.ServerVersion property to obtain textual representation of the version. If you use System.Runtime.InteropServices.Version object then you can construct one to parse such things like major and minor numbers.

It works for AS2005 and AS2000.|||Works a treat Andrew thanks

Get a value

This is my code...

Sub btnLogin_OnClick(Src As Object, E As EventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim intUserCount As Integer
Dim strSQL As String

strSQL = "SELECT COUNT(*) FROM tblLoginInfo WHEREusername=@.UserName AND

password=@.Password"

myConnection = New SqlConnection("server=

(local);database=Database;trusted_connection=true")

myCommand = New SqlCommand(strSQL, myConnection)

myCommand.Parameters.add("@.UserName",sqldbtype.varchar).value=txtUserName.text

myCommand.Parameters.add("@.Password",sqldbtype.varchar).value=txtPassword.text

myConnection.Open()
intUserCount = myCommand.ExecuteScalar()
myConnection.Close()

If intUserCount > 0 Then
lblInvalid.Text = ""
FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
Response.Redirect("login_db-protected.aspx")
Else
lblInvalid.Text = "Sorry... try again..."
End If
End Sub


On the table 'tblLoginInfo' there are 3 fields... username, password and destination.
When a user clicks on the btnLogin... i want to get the value of the destination field that

lines up with the same username and password fields and place it in a string called 'test'.

Cannning

Hi, just replace count(*) with destination:

strSQL = "SELECT destination FROM tblLoginInfo WHEREusername=@.UserName AND

password=@.Password"

myConnection = New SqlConnection("server=

(local);database=Database;trusted_connection=true")

myCommand = New SqlCommand(strSQL, myConnection)

myCommand.Parameters.add("@.UserName",sqldbtype.varchar).value=txtUserName.text

myCommand.Parameters.add("@.Password",sqldbtype.varchar).value=txtPassword.text

myConnection.Open()

string test = (string) myCommand.ExecuteScalar ( ) ;

myConnection.Close()

Hope this helps

Wednesday, March 21, 2012

Generating script per object

Hi,
I want to generate Script for 4 Stored Procedures at a time in SQL SERVER 2005 as 4 seperate files.

In SQL SERVER 2000 there is a option
-Script file per object, using which we can generate script only once for all the 4 sps as 4 seperate files
Is there any such option in 2005?

Please suggest.

Thanks in advance

Ram

They added this feature to the Scripting Wizard in SP2.|||

Jason Callas wrote:

They added this feature to the Scripting Wizard in SP2.

To elaborate a little bit more... if you use the Generate Script Wizard in SQL Server 2005 SP2, you can choose to create one file per object.

Steps:

1) Right-click on a database -> Tasks -> Generate Scripts...

2) On the "Output Option" screen

a) Choose "Script to file"

b) Choose "File per object"

Paul A. Mestemaker II

Program Manager

Microsoft SQL Server Manageability

http://blogs.msdn.com/sqlrem/

sql

Monday, March 19, 2012

Generating DTS flat file connection

I'm trying to generate a DTS Package with VB.Net using the Microsoft DTSPackage Object Library and
and the Microsoft DTSDataPump Scripting Object Library
I have to load csv files into SQL tables.
I could generate both a SQL connection and a FlatFile connection and the transformationtask.

When I look at the transformationtask and click on the transformation tab I get this error

"Incomple file format information"

The problem is I don't find where I could set the FlatFile connection properties like "Text Qualifier" and
"row delimiter"

I tried this but it still shows CRLF as row delimiter when I look at the generated DTS Package

Dim oConnection As DTS.Connection2
Dim package As DTS.Package2
Dim filename As String
filename = "myfilename.csv"

oConnection = package.Connections.New("DTSFlatFile")
oConnection.Name = filename
oConnection.ConnectionProperties.Item("Row Delimiter").Value = vbTabWhy not just bcp the file out using a stored porcedure?

generating DDL

In Oracle, there is a system packaged function that returns the DDL for a
database object (DBMS_METADATA.GET_DDL). What is the equivalent in SQL
Server?you can generate DDL from an object using Query Analyzer by
right-clicking the object in the object browser and selecting "Script
Object to <dest> as <action>"
- Baileys
arch wrote:
> In Oracle, there is a system packaged function that returns the DDL for a
> database object (DBMS_METADATA.GET_DDL). What is the equivalent in SQL
> Server?
>|||Yes, I know. But I wanted the DDL to be used in a query. I need a function
or something that returns so I can use it in an SQL statement.
"Baileys" <no_email@.server.com> wrote in message
news:%23%23B7GGLhGHA.3956@.TK2MSFTNGP02.phx.gbl...
> you can generate DDL from an object using Query Analyzer by right-clicking
> the object in the object browser and selecting "Script Object to <dest> as
> <action>"
> - Baileys
> arch wrote:|||You can use SQL DMO to get a table object and then use the script function t
o
script out the table.
You can search for the script function in Books Online. If you need this as
a function look for activating COM objects though the use of extended stored
procedures.
Arun
"arch" wrote:

> Yes, I know. But I wanted the DDL to be used in a query. I need a functi
on
> or something that returns so I can use it in an SQL statement.
> "Baileys" <no_email@.server.com> wrote in message
> news:%23%23B7GGLhGHA.3956@.TK2MSFTNGP02.phx.gbl...
>
>|||arch wrote:
> Yes, I know. But I wanted the DDL to be used in a query. I need a functi
on
> or something that returns so I can use it in an SQL statement.
>
You can't directly generate SQL from within SQL code itself.
As another poster said, you can use DMO, which is a COM object (aka
ActiveX), with some surrounding code, to build your SQL statements,
then submit the to the database.
Or, in some cases you could roll your own sql-building code that would
work within SQL. If you're interested in tables, for example, the
metatable INFORMATION_SCHEMA.COLUMNS can give you column names, data
types and lengths; INFORMATION_SCHEME.CONSTRAINT_COLUMN_USAGE gives
information about which columns are involved in constraints, etc. That
would be a particularly tedious path to have to follow, in my opinion.

Generating an SQL script for a DTS Package

Can an SQL script be generated for a DTS package? I need to be able to
create script to recreate every object that relates to the normal
functioning of the database. Most other objects are easy to get an
executable script to recreate. I can't seem to figure this one out.
Thank you,
JulianDTS packages can include non-SQL structures like VBscripts etc. So the only
ways, you can save them as structured storage file, VB file, Metadata
Service or as binary data in MSDB database. Each of the options can be found
in SQL Server Books Online under the topic "saving DTS packages"
Anith

Friday, March 9, 2012

Generate sysdepends list

:shocked: I can't seem to find a way of gettng a list of the view/stored procedure/UDF dependencies by object. Any ideas?What program are you using to do this?|||I am using ASP and vbscript to access the list and it is not retreiving all of the dependencies.:eek:|||Microsoft SQL doesn't guarantee 100% coverage for sysdepends. There will be some cases where you won't have a row that should be there.

-PatP|||Thanks Pat. I found shrinking the database brings newer dependencies into the list. Odd.:shocked:|||If a DDL script creates an object that references an object that does not yet exist (for instance, it is created later on...), then the first object will be created anyway but an entry will not be added to sysdepends. It should generate a warning to notify you of this.|||I create any dependencies a new store procedure, UDF or view needs first before creating the new piece to avoid the errors associated with referenced unknowns. Thanks for the tip.:)

Generate SQL scripts creating a separate file per object

Hello all,

What is an easy way of scripting all the database tables and sprocs automatically to a separate file each one? I can't find this option in SQL Server Management Studio.

Or is any other way of uploading all objects to a Visual Source Safe project that does not require to copy and paste each script into a VSS sql script?

Thanks!

David

Using SQL Server 2005, right click the database, choose Tasks-> Generate Scripts. You should see a new window open with an info screen. Click Next. Now you should be at the 'Select Database' screen. Select the database you want to generate scripts for, then check the "Script all objects in the selected database" checkbox. Click Next.

Now make sure your script options are correct. If you use the default properties for SQL Server setup, then default should be fine for this as well. Click Next after making any necessary changes.

Now you are at the "Output Option" screen. Select the "Script to file" radio button, and under "Files to generate", select the "File per object" option. Make sure you set your save location and encoding, if necessary.

At this point, you can either click Next to view a summary of what you just selected, or you can click Finish to start scripting. (There is also a "Finish" button on the summary screen.)

|||

That "File per Object" option does not appear in my SQL Server Manager 2005.

I think I have installed the latest service pack.

|||

neutrino:

That "File per Object" option does not appear in my SQL Server Manager 2005.

I think I have installed the latest service pack.

I'm not sure if it has to do with the service pack. I have two computers that should both be updated to the latest SP. However, I was able to reproduce this problem with a machine running XP Pro, and the SQL Server Management Studio version was 9.00.1399.x.

The version this works on is 9.00.3042.x, and it is running on Server 2003.

Both computers only have the Development version installed, so maybe it has to do with being on a server OS?

Sunday, February 26, 2012

Generate SCRIPT

Hello,
Using the new "SQL Server Management Studio" for SQL Server 2005, how would
I generate scripts for more than one object at a time. Let us say I want to
generate scripts for all tables, how would I do that?.
Thanks,
Ganesh
You can select multiple objects displayed in the Summary
page - then right click and script.
-Sue
On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
<GaneshMuthuvelu@.discussions.microsoft.com> wrote:

>Hello,
>Using the new "SQL Server Management Studio" for SQL Server 2005, how would
>I generate scripts for more than one object at a time. Let us say I want to
>generate scripts for all tables, how would I do that?.
>Thanks,
>Ganesh
|||Where is this "Summary Page"?. Sorry, could you expalin it a little more?.
Thanks,
Ganesh
"Sue Hoegemeier" wrote:

> You can select multiple objects displayed in the Summary
> page - then right click and script.
> -Sue
> On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
> <GaneshMuthuvelu@.discussions.microsoft.com> wrote:
>
>
|||From Object Explorer...Right-click database...tasks...generate scripts
i think you can figure out the rest.
HTH,
JL
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in
message news:B59BAC5D-1499-4F45-919E-1967F02F5382@.microsoft.com...
> Hello,
> Using the new "SQL Server Management Studio" for SQL Server 2005, how
> would
> I generate scripts for more than one object at a time. Let us say I want
> to
> generate scripts for all tables, how would I do that?.
> Thanks,
> Ganesh
|||Under the defaults, It's to the right of registered servers
and object explorer when you first open up Management
Studio. Otherwise, hit F7 to display it. Or from the Menu go
to view and then select Summary.
-Sue
On Fri, 20 Jan 2006 12:57:04 -0800, "Ganesh Muthuvelu"
<GaneshMuthuvelu@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Where is this "Summary Page"?. Sorry, could you expalin it a little more?.
>Thanks,
>Ganesh
>"Sue Hoegemeier" wrote:

Generate SCRIPT

Hello,
Using the new "SQL Server Management Studio" for SQL Server 2005, how would
I generate scripts for more than one object at a time. Let us say I want to
generate scripts for all tables, how would I do that?.
Thanks,
GaneshYou can select multiple objects displayed in the Summary
page - then right click and script.
-Sue
On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
<GaneshMuthuvelu@.discussions.microsoft.com> wrote:

>Hello,
>Using the new "SQL Server Management Studio" for SQL Server 2005, how would
>I generate scripts for more than one object at a time. Let us say I want to
>generate scripts for all tables, how would I do that?.
>Thanks,
>Ganesh|||Where is this "Summary Page"?. Sorry, could you expalin it a little more?.
Thanks,
Ganesh
"Sue Hoegemeier" wrote:

> You can select multiple objects displayed in the Summary
> page - then right click and script.
> -Sue
> On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
> <GaneshMuthuvelu@.discussions.microsoft.com> wrote:
>
>|||From Object Explorer...Right-click database...tasks...generate scripts
i think you can figure out the rest.
HTH,
JL
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in
message news:B59BAC5D-1499-4F45-919E-1967F02F5382@.microsoft.com...
> Hello,
> Using the new "SQL Server Management Studio" for SQL Server 2005, how
> would
> I generate scripts for more than one object at a time. Let us say I want
> to
> generate scripts for all tables, how would I do that?.
> Thanks,
> Ganesh|||Under the defaults, It's to the right of registered servers
and object explorer when you first open up Management
Studio. Otherwise, hit F7 to display it. Or from the Menu go
to view and then select Summary.
-Sue
On Fri, 20 Jan 2006 12:57:04 -0800, "Ganesh Muthuvelu"
<GaneshMuthuvelu@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Where is this "Summary Page"?. Sorry, could you expalin it a little more?.
>Thanks,
>Ganesh
>"Sue Hoegemeier" wrote:
>

Generate SCRIPT

Hello,
Using the new "SQL Server Management Studio" for SQL Server 2005, how would
I generate scripts for more than one object at a time. Let us say I want to
generate scripts for all tables, how would I do that?.
Thanks,
GaneshYou can select multiple objects displayed in the Summary
page - then right click and script.
-Sue
On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
<GaneshMuthuvelu@.discussions.microsoft.com> wrote:
>Hello,
>Using the new "SQL Server Management Studio" for SQL Server 2005, how would
>I generate scripts for more than one object at a time. Let us say I want to
>generate scripts for all tables, how would I do that?.
>Thanks,
>Ganesh|||From Object Explorer...Right-click database...tasks...generate scripts
i think you can figure out the rest.
HTH,
JL
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in
message news:B59BAC5D-1499-4F45-919E-1967F02F5382@.microsoft.com...
> Hello,
> Using the new "SQL Server Management Studio" for SQL Server 2005, how
> would
> I generate scripts for more than one object at a time. Let us say I want
> to
> generate scripts for all tables, how would I do that?.
> Thanks,
> Ganesh|||Where is this "Summary Page"?. Sorry, could you expalin it a little more?.
Thanks,
Ganesh
"Sue Hoegemeier" wrote:
> You can select multiple objects displayed in the Summary
> page - then right click and script.
> -Sue
> On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
> <GaneshMuthuvelu@.discussions.microsoft.com> wrote:
> >Hello,
> >Using the new "SQL Server Management Studio" for SQL Server 2005, how would
> >I generate scripts for more than one object at a time. Let us say I want to
> >generate scripts for all tables, how would I do that?.
> >
> >Thanks,
> >Ganesh
>|||Under the defaults, It's to the right of registered servers
and object explorer when you first open up Management
Studio. Otherwise, hit F7 to display it. Or from the Menu go
to view and then select Summary.
-Sue
On Fri, 20 Jan 2006 12:57:04 -0800, "Ganesh Muthuvelu"
<GaneshMuthuvelu@.discussions.microsoft.com> wrote:
>Where is this "Summary Page"?. Sorry, could you expalin it a little more?.
>Thanks,
>Ganesh
>"Sue Hoegemeier" wrote:
>> You can select multiple objects displayed in the Summary
>> page - then right click and script.
>> -Sue
>> On Fri, 20 Jan 2006 11:13:02 -0800, "Ganesh Muthuvelu"
>> <GaneshMuthuvelu@.discussions.microsoft.com> wrote:
>> >Hello,
>> >Using the new "SQL Server Management Studio" for SQL Server 2005, how would
>> >I generate scripts for more than one object at a time. Let us say I want to
>> >generate scripts for all tables, how would I do that?.
>> >
>> >Thanks,
>> >Ganesh
>>