Showing posts with label express. Show all posts
Showing posts with label express. Show all posts

Thursday, March 29, 2012

Get All Servers and Databases from MSSQL Server 2005 Express

Is there any way to get all available servers and databases from Microsoft SQL Server 2005 Express without connecting to it at all? I am trying to write an application that uses SS05E and I would like to have an option to display all available servers and databases.

check SQLCMD. Form command prompt ...

for all the sql server instance in a network - sqlcmd -L

to get all the database name from a sql server instance -- sqlcmd -q"Select *from sys.databases' -SserverName -Ppassword

Madhu

|||There is no way to pull a list of databases from the servers without connecting to the databases. sqlcmd with the -L switch can output all the SQL Servers on your Windows network. You would need to log into each one and pull the database list from the master.dbo.sysdatabases or sys.databases objects to see what databases are available on each.|||That will work fine. Is there any way I can run sqlcmd -L in a vb.net program and get the results put into a string array? I am writing an application that uses SQL Server and I want the servers/databases to be put into combo boxes or list boxes to make it easier to select which server/database to use.|||

I found something google that will work perfectly for what I need. Here is the code:

Code Snippet

Try

Dim myprocess As New Process

Dim StartInfo As New System.Diagnostics.ProcessStartInfo

StartInfo.FileName = "cmd" 'starts cmd window

StartInfo.RedirectStandardInput = True

StartInfo.RedirectStandardOutput = True

StartInfo.UseShellExecute = False 'required to redirect

StartInfo.CreateNoWindow = True 'creates no cmd window

myprocess.StartInfo = StartInfo

myprocess.Start()

Dim SR As System.IO.StreamReader = myprocess.StandardOutput

Dim SW As System.IO.StreamWriter = myprocess.StandardInput

SW.WriteLine("sqlcmd -L") 'the command you wish to run.....

SW.WriteLine("exit") 'exits command prompt window

Me.txtOutput.Text = SR.ReadToEnd 'returns results of the command window

SW.Close()

SR.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Thanks for your help in getting me this far! I really appreciate it

Monday, March 12, 2012

generated insert statement

using ms sql 2005 express,
created a simple two field table
tried to configure the data adapter in vb 2003 and the wizard returns
"Generated INSERT statement. There were errors configuring the data adapter"
No description of the error. The insert, update and delete procs are not
generated.
What am I doing wrong'
--
Ranbdy KrofickI don't think that wizard works with 2005 - it reads the
meta data tables which are different in SQL Server 2005 than
they were in previous versions of SQL Server. You'll need to
write your own code - and you'll be better off anyway.
-Sue
On Mon, 5 Mar 2007 15:33:03 -0800, Randy Krofick
<randyk@.nwinds.com> wrote:

>using ms sql 2005 express,
>created a simple two field table
>tried to configure the data adapter in vb 2003 and the wizard returns
>"Generated INSERT statement. There were errors configuring the data adapter
"
>No description of the error. The insert, update and delete procs are not
>generated.
>What am I doing wrong'

generated insert statement

using ms sql 2005 express,
created a simple two field table
tried to configure the data adapter in vb 2003 and the wizard returns
"Generated INSERT statement. There were errors configuring the data adapter"
No description of the error. The insert, update and delete procs are not
generated.
What am I doing wrong'
--
Ranbdy KrofickI don't think that wizard works with 2005 - it reads the
meta data tables which are different in SQL Server 2005 than
they were in previous versions of SQL Server. You'll need to
write your own code - and you'll be better off anyway.
-Sue
On Mon, 5 Mar 2007 15:33:03 -0800, Randy Krofick
<randyk@.nwinds.com> wrote:
>using ms sql 2005 express,
>created a simple two field table
>tried to configure the data adapter in vb 2003 and the wizard returns
>"Generated INSERT statement. There were errors configuring the data adapter"
>No description of the error. The insert, update and delete procs are not
>generated.
>What am I doing wrong'

generated insert statement

using ms sql 2005 express,
created a simple two field table
tried to configure the data adapter in vb 2003 and the wizard returns
"Generated INSERT statement. There were errors configuring the data adapter"
No description of the error. The insert, update and delete procs are not
generated.
What am I doing wrong?
Ranbdy Krofick
I don't think that wizard works with 2005 - it reads the
meta data tables which are different in SQL Server 2005 than
they were in previous versions of SQL Server. You'll need to
write your own code - and you'll be better off anyway.
-Sue
On Mon, 5 Mar 2007 15:33:03 -0800, Randy Krofick
<randyk@.nwinds.com> wrote:

>using ms sql 2005 express,
>created a simple two field table
>tried to configure the data adapter in vb 2003 and the wizard returns
>"Generated INSERT statement. There were errors configuring the data adapter"
>No description of the error. The insert, update and delete procs are not
>generated.
>What am I doing wrong?

Friday, March 9, 2012

generate table scripts

Hi

I'm developing a website using SQL Server Express 2005 and VIsual Web Developer Express, and now want to start testing my website in a live environment. Until now I have been manually creating tables on my web database to match those on my local DB, but I have so many tables I don't want to manually recreate them all again. Is there a method in SQL Server Express 2005 that will allow me to generate insert scripts for all the tables?

Cheers

Andy

This should help

http://weblogs.asp.net/scottgu/archive/2006/12/22/recipe-deploying-a-sql-database-to-a-remote-hosting-environment-part-1.aspx

|||

Download the SQL Server Database Publishing Wizard:

http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en

Jos

|||

Blimey! That was quick. Thanks for the prompt responses, guys!

Wednesday, March 7, 2012

Generate Scripts Problem.

Hi all,
I am using the generate Script feature of SQL Server 2005 Express.
The result is:
CREATE TABLE [dbo].[asmt_v2_areas](
[asmt_v2_area_id] [int] IDENTITY(1,1) NOT NULL,
[asmt_v2_mine_id] [int] NULL,
[name] [varchar](60) NOT NULL,
[parent_id] [int] NULL,
[optional_questions] [tinyint] NULL,
[send_updates] [tinyint] NULL,
CONSTRAINT [PK_asmt_v2_areas] PRIMARY KEY CLUSTERED
(
[asmt_v2_area_id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] //error here
) ON [PRIMARY]
END
However, when i try an run these scripts without modification, i keep
getting the error 'Syntax error near ')' on the line above.
I am exporting to 2000 servers, could this be the problem?
Any thoughts on how to fix?
Cheers,
AdamThere are some elements in the generated script which are new to 2005. I don
't know exactly what
tool you use to generate script, but perhaps that tool has some option to ge
nerate it with 2000
compatibility.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Mr Ideas Man" <adam@.pertrain.com.au> wrote in message news:O1PtNWNPGHA.3924@.TK2MSFTNGP14.p
hx.gbl...
> Hi all,
> I am using the generate Script feature of SQL Server 2005 Express.
> The result is:
> CREATE TABLE [dbo].[asmt_v2_areas](
> [asmt_v2_area_id] [int] IDENTITY(1,1) NOT NULL,
> [asmt_v2_mine_id] [int] NULL,
> [name] [varchar](60) NOT NULL,
> [parent_id] [int] NULL,
> [optional_questions] [tinyint] NULL,
> [send_updates] [tinyint] NULL,
> CONSTRAINT [PK_asmt_v2_areas] PRIMARY KEY CLUSTERED
> (
> [asmt_v2_area_id] ASC
> )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] //error here
> ) ON [PRIMARY]
> END
> However, when i try an run these scripts without modification, i keep gett
ing the error 'Syntax
> error near ')' on the line above.
> I am exporting to 2000 servers, could this be the problem?
> Any thoughts on how to fix?
> Cheers,
> Adam
>
>|||Hi Tibor,
Yeah, I am using SQL Server 2005 and selecting from the relevant dialog
'export as SqlServer 2000' but the error persists.
Bit of a tricky one.
Cheers,
Adam
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:Obvu2bPPGHA.3408@.TK2MSFTNGP12.phx.gbl...
> There are some elements in the generated script which are new to 2005. I
> don't know exactly what tool you use to generate script, but perhaps that
> tool has some option to generate it with 2000 compatibility.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Mr Ideas Man" <adam@.pertrain.com.au> wrote in message
> news:O1PtNWNPGHA.3924@.TK2MSFTNGP14.phx.gbl...
>|||What tool are you using? SQL Server Management Studio? You mentioned Express
, and I'm a bit thrown
off since that doesn't come with any GUI tool.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mr Ideas Man" <adam@.pertrain.com.au> wrote in message
news:%23HEEkfPPGHA.3936@.TK2MSFTNGP12.phx.gbl...
> Hi Tibor,
> Yeah, I am using SQL Server 2005 and selecting from the relevant dialog 'e
xport as SqlServer 2000'
> but the error persists.
> Bit of a tricky one.
> Cheers,
> Adam
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n message
> news:Obvu2bPPGHA.3408@.TK2MSFTNGP12.phx.gbl...
>

Generate scripts doesn''t take into account dependencies

I'm having a problem with the generate scripts procedure in Sql Server Express. My database has stored procedures which use views. When I generate the database create script it puts the stored procedures before the views, so that the create script fails when I try to execute it, because the stored procedure can't be compiled until the view is defined. Is there a fix for this or a way around the problem?

Jon Webb

I found a workaround / fix: 1) Make the objects I was having trouble with schema bound; 2) Check "generate dependent objects" in the generate scripts wizard.

Generate scripts doesn''t take into account dependencies

I'm having a problem with the generate scripts procedure in Sql Server Express. My database has stored procedures which use views. When I generate the database create script it puts the stored procedures before the views, so that the create script fails when I try to execute it, because the stored procedure can't be compiled until the view is defined. Is there a fix for this or a way around the problem?

Jon Webb

I found a workaround / fix: 1) Make the objects I was having trouble with schema bound; 2) Check "generate dependent objects" in the generate scripts wizard.

Sunday, February 26, 2012

Generate Script and Insert Data

I have a question regarding generating SQL script from a database.If you use SQL Server Management Express, it lets you generate SQLscript that can be used to recreate table structure, stored procedures,etc. But it does not include the actual data stored in the tables.

Is it possible to generate SQL to *INSERT* data as well? If yes, then how?

You can get a template query for inserting data to 1 table by right clicking the table in Object Explorer->choose Script Table As->INSERT To. However there is no such generated script to do actual INSERTs and it is not necessary, because there are serveral easy way to transfer data into the new table, for example you can just use such INSERT command:

INSERT INTO newTable SELECT * FROM oldTable

|||

Here is software that does exactly what you want:http://www.denovations.com/products/sqlpopulator/

I'm using it by myself while creating database installation script and should say this solution matched all my requirements.

Friday, February 24, 2012

generate db scrip including data in tables

i'm not able to generate a sql script with the data in the tables! using sql express.

i need this script to ganerate the same database with its datas in a new sql server.

thanks in advance

SQL Server only generates scripts for schema and not for data. There are 3rd party tools that can do that. You can either build a DTS package or use DTS Import Export wizard to transfer data across servers. If the tables are huge (tens of millions of rows or higher) the DTS/Import could be slower.

|||

Can u just take a backup of the database on the source server and restore it on the destination server. This is of course possible if you need the entire database. Unfortunately, you can't create a script or something for data in the database like the script for the definitions of the objects (tables, stored procedures, views etc.). DTS packages are another solution as suggested by ndinakar.