Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts

Monday, March 19, 2012

How to create a series of tables with a variable name?

hi all,
I am new to MSSQL and I am thinking whether I can create a table with its name containing a variable. That is , I want to create a variable number of tables depending on the parameter passed to the stored procedure. Need Help on that. Thanks in advance.yes you can easily do that by little programming knowledge.|||

Quote:

Originally Posted by heavenl

hi all,
I am new to MSSQL and I am thinking whether I can create a table with its name containing a variable. That is , I want to create a variable number of tables depending on the parameter passed to the stored procedure. Need Help on that. Thanks in advance.


HI
I am sending an example .It will help you
[code]
create pro pro1(@.a int)
as
begin
while(@.a>0)
begin
exec('create table table+'+@.a)
set @.a=@.a-1
end
end

Monday, March 12, 2012

How to create a linked server to MySQL from MsSQL?

I can create a linked server to another MsSQL from MsSQL,but encounter error when create a linked server to MySQL:
Error 7399:OLE DB provider 'MSDASQL' reported an error.
Data source name not found and no default driver specified.
.....
Anyone can help me?
Thanks!try this step,

1. Installed MyODBC driver version for windows,u can download from mysql site
2. Create a system ODBC DSN using this driver to a specific server and database.

3. In SQL Server 2K Enterprise Manager, created a linked server using Microsoft OLE DB Provider for ODBC Drivers and specified the DSN in the Data Source.

and select query should be,

SELECT * FROM OPENQUERY(linkedservername, 'database.table')

or

SELECT * FROM OPENQUERY(linkedservername, 'select * from table)

--cheers,
--http://mallier.blogspot.com|||Yes,I did as you said.But still get this error.

The setting are:
Server Type:Microsoft OLE DB Provider for ODBC
DataSource:mydsn
Provider string:DATABASE=mydb;DSN=mydsn;SERVER=myserver;UID =myuid;PWD=mypwd
Location:myserver
Catalog:mydb

Something is wrong?|||I dont have Mysql here,
try this,

Server Type:Microsoft OLE DB Provider for ODBC
DataSource:mydsn

and remove other properties.

--cheers,
--http://mallier.blogspot.com|||Even I linked to the MsSQL server NOT MySQL,
if put myserver in data source,it's ok.
but if put mydsn in data source,it got same error.|||Sorry,I created dns in wrong location.
After I corrected this mistake,linking to MsSQL is ok,but encountered not responding when link to MySQL.(I've verified that the dsn is ok.)|||I've fixed this problem,it's due to I didn't enable root access from remote machines.
Thanks.

Friday, March 9, 2012

How to create a DUMP table in MSSQL

In mySQL it is easy to create a DUMP table which when run creates the table and inserts the data ....

In MSSQL I can create a file which I can use to re-create the table but I can not see how to also add the data with out doing a backup in MSSQL ... anyone know where this is possible?

There are a couple of choices;

1/ export the data out as text by using BCP or Integration Services.
2/ Instead of scripting data and schema just detach the database from one instance, copy it and then attach on the other end.

BCP is a sql solution, there is UI for the others under All Tasks on a right click.

How to create a database on pendrive using MSSQL 7.0?

Hey friends,
I want create a database on a usb pendrive and acess it my server is
MSSQL 7.0 when ever i plugin the pend drive.
Please let me know the the procedure .. this is a chellenging job..
Thank You
regards

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Hi

SQL Server does not support plug and play in such a way. There is a means to
create databases on removable media (avaiable in SQL 2000 but I can't check
SQL 7) called sp_create_removable, which is aimed at distributing databases
on read only media.

Therefore you will have to manually make sure that the database was
detached/attached correctly
http://support.microsoft.com/defaul...kb;EN-US;224071

Personally I would only store a backup on removably media like this and
overwrite/restore it when necessary.

John

"Vikram Jain" <vicky_j77@.hotmail.com> wrote in message
news:4143f445$0$26124$c397aba@.news.newsgroups.ws.. .
> Hey friends,
> I want create a database on a usb pendrive and acess it my server is
> MSSQL 7.0 when ever i plugin the pend drive.
> Please let me know the the procedure .. this is a chellenging job..
> Thank You
> regards
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!|||John Bell (jbellnewsposts@.hotmail.com) writes:
> SQL Server does not support plug and play in such a way. There is a
> means to create databases on removable media (avaiable in SQL 2000 but I
> can't check SQL 7) called sp_create_removable, which is aimed at
> distributing databases on read only media.

I made a quick check, and sp_create_removable is available on SQL7.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

How to create a BAK of MSSQL database?

Hi,
WebAssist have asked us to provide them with a BAK of our MSSQL database.
Can anyone provide instruction on how to do that? We are using Enterprise
Manager and our database is hosted by our ISP on their server, which we have
access to.
Thanks
Nath.
Hi
BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
> Hi,
> WebAssist have asked us to provide them with a BAK of our MSSQL database.
> Can anyone provide instruction on how to do that? We are using Enterprise
> Manager and our database is hosted by our ISP on their server, which we
> have access to.
> Thanks
> Nath.
>
|||Hi Uri,
Thank you very much.
Regards
nath.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23BCJGDdQGHA.2300@.TK2MSFTNGP11.phx.gbl...
> Hi
> BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
>
>
> "Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
> news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
>
|||No file though?
SQL SERVER BACKUP
database name: ourdbname
name: our backup
description: <blank>
Backup - we have "database complete" selected
Destination - we have C:\ourdbase.bak
When we click "OK" it seems to run through everything successfully, except
there is no ourdbase.bak file on our C drive! Are we saving it to our ISP's
C drive considering that the MSSQL database is hosted there?
Hope you can help. Thanks again.
Regards
Nath.
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:%23P5JDGdQGHA.516@.TK2MSFTNGP15.phx.gbl...
> Hi Uri,
> Thank you very much.
> Regards
> nath.
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23BCJGDdQGHA.2300@.TK2MSFTNGP11.phx.gbl...
>
|||Yes path are always relative to the server you are working on.
HTH, Jens Suessmeyer.
|||Hi,
Is there any way to save the file locally? Our ISP (Fasthosts) don't seem
to understand what we are asking them and keep trying to force us to use DTS
to backup the database.
We've got Microsoft SQL Server 8.0 installed but, to be honest, we're just
using this to link to 2 databases hosted by our ISP.
How do we create a MSSQL database locally, so that we could import the data
in and THEN do the All Tasks > Database Backup?
Thanks
Nath.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1141728051.055622.165600@.z34g2000cwc.googlegr oups.com...
> Yes path are always relative to the server you are working on.
> HTH, Jens Suessmeyer.
>
|||> Is there any way to save the file locally?
That would require that the account that the SQL Server service is running under at your ISP had
connection and permissions to a share on your machine. Not likely, and not something you want. This
is how windows work. How about backup locally at your ISP and then FTP the file? If your ISP don't
give you an option to backup and save the backup locally you should change ISP immediately...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:%23U4%23kodQGHA.5808@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to save the file locally? Our ISP (Fasthosts) don't seem to understand what we
> are asking them and keep trying to force us to use DTS to backup the database.
> We've got Microsoft SQL Server 8.0 installed but, to be honest, we're just using this to link to 2
> databases hosted by our ISP.
> How do we create a MSSQL database locally, so that we could import the data in and THEN do the All
> Tasks > Database Backup?
> Thanks
> Nath.
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1141728051.055622.165600@.z34g2000cwc.googlegr oups.com...
>

How to create a BAK of MSSQL database?

Hi,
WebAssist have asked us to provide them with a BAK of our MSSQL database.
Can anyone provide instruction on how to do that? We are using Enterprise
Manager and our database is hosted by our ISP on their server, which we have
access to.
Thanks
Nath.Hi
BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
> Hi,
> WebAssist have asked us to provide them with a BAK of our MSSQL database.
> Can anyone provide instruction on how to do that? We are using Enterprise
> Manager and our database is hosted by our ISP on their server, which we
> have access to.
> Thanks
> Nath.
>|||Hi Uri,
Thank you very much.
Regards
nath.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23BCJGDdQGHA.2300@.TK2MSFTNGP11.phx.gbl...
> Hi
> BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
>
>
> "Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
> news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
>> Hi,
>> WebAssist have asked us to provide them with a BAK of our MSSQL database.
>> Can anyone provide instruction on how to do that? We are using
>> Enterprise Manager and our database is hosted by our ISP on their server,
>> which we have access to.
>> Thanks
>> Nath.
>|||No file though?
SQL SERVER BACKUP
database name: ourdbname
name: our backup
description: <blank>
Backup - we have "database complete" selected
Destination - we have C:\ourdbase.bak
When we click "OK" it seems to run through everything successfully, except
there is no ourdbase.bak file on our C drive! Are we saving it to our ISP's
C drive considering that the MSSQL database is hosted there?
Hope you can help. Thanks again.
Regards
Nath.
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:%23P5JDGdQGHA.516@.TK2MSFTNGP15.phx.gbl...
> Hi Uri,
> Thank you very much.
> Regards
> nath.
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23BCJGDdQGHA.2300@.TK2MSFTNGP11.phx.gbl...
>> Hi
>> BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
>>
>>
>> "Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
>> news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
>> Hi,
>> WebAssist have asked us to provide them with a BAK of our MSSQL
>> database.
>> Can anyone provide instruction on how to do that? We are using
>> Enterprise Manager and our database is hosted by our ISP on their
>> server, which we have access to.
>> Thanks
>> Nath.
>>
>|||Yes path are always relative to the server you are working on.
HTH, Jens Suessmeyer.|||Hi,
Is there any way to save the file locally? Our ISP (Fasthosts) don't seem
to understand what we are asking them and keep trying to force us to use DTS
to backup the database.
We've got Microsoft SQL Server 8.0 installed but, to be honest, we're just
using this to link to 2 databases hosted by our ISP.
How do we create a MSSQL database locally, so that we could import the data
in and THEN do the All Tasks > Database Backup?
Thanks
Nath.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1141728051.055622.165600@.z34g2000cwc.googlegroups.com...
> Yes path are always relative to the server you are working on.
> HTH, Jens Suessmeyer.
>|||> Is there any way to save the file locally?
That would require that the account that the SQL Server service is running under at your ISP had
connection and permissions to a share on your machine. Not likely, and not something you want. This
is how windows work. How about backup locally at your ISP and then FTP the file? If your ISP don't
give you an option to backup and save the backup locally you should change ISP immediately...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:%23U4%23kodQGHA.5808@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to save the file locally? Our ISP (Fasthosts) don't seem to understand what we
> are asking them and keep trying to force us to use DTS to backup the database.
> We've got Microsoft SQL Server 8.0 installed but, to be honest, we're just using this to link to 2
> databases hosted by our ISP.
> How do we create a MSSQL database locally, so that we could import the data in and THEN do the All
> Tasks > Database Backup?
> Thanks
> Nath.
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1141728051.055622.165600@.z34g2000cwc.googlegroups.com...
>> Yes path are always relative to the server you are working on.
>> HTH, Jens Suessmeyer.
>

How to create a BAK of MSSQL database?

Hi,
WebAssist have asked us to provide them with a BAK of our MSSQL database.
Can anyone provide instruction on how to do that? We are using Enterprise
Manager and our database is hosted by our ISP on their server, which we have
access to.
Thanks
Nath.Hi
BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
> Hi,
> WebAssist have asked us to provide them with a BAK of our MSSQL database.
> Can anyone provide instruction on how to do that? We are using Enterprise
> Manager and our database is hosted by our ISP on their server, which we
> have access to.
> Thanks
> Nath.
>|||Hi Uri,
Thank you very much.
Regards
nath.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23BCJGDdQGHA.2300@.TK2MSFTNGP11.phx.gbl...
> Hi
> BACKUP DATABASE mydb TO DISK ='C:\mydb.bak'
>
>
> "Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
> news:OMVgNucQGHA.5296@.TK2MSFTNGP09.phx.gbl...
>|||No file though?
SQL SERVER BACKUP
database name: ourdbname
name: our backup
description: <blank>
Backup - we have "database complete" selected
Destination - we have C:\ourdbase.bak
When we click "OK" it seems to run through everything successfully, except
there is no ourdbase.bak file on our C drive! Are we saving it to our ISP's
C drive considering that the MSSQL database is hosted there?
Hope you can help. Thanks again.
Regards
Nath.
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:%23P5JDGdQGHA.516@.TK2MSFTNGP15.phx.gbl...
> Hi Uri,
> Thank you very much.
> Regards
> nath.
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23BCJGDdQGHA.2300@.TK2MSFTNGP11.phx.gbl...
>|||Yes path are always relative to the server you are working on.
HTH, Jens Suessmeyer.|||Hi,
Is there any way to save the file locally? Our ISP (Fasthosts) don't seem
to understand what we are asking them and keep trying to force us to use DTS
to backup the database.
We've got Microsoft SQL Server 8.0 installed but, to be honest, we're just
using this to link to 2 databases hosted by our ISP.
How do we create a MSSQL database locally, so that we could import the data
in and THEN do the All Tasks > Database Backup?
Thanks
Nath.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1141728051.055622.165600@.z34g2000cwc.googlegroups.com...
> Yes path are always relative to the server you are working on.
> HTH, Jens Suessmeyer.
>|||> Is there any way to save the file locally?
That would require that the account that the SQL Server service is running u
nder at your ISP had
connection and permissions to a share on your machine. Not likely, and not s
omething you want. This
is how windows work. How about backup locally at your ISP and then FTP the f
ile? If your ISP don't
give you an option to backup and save the backup locally you should change I
SP immediately...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Nathon Jones" <sales@.NOSHPAMtradmusic.com> wrote in message
news:%23U4%23kodQGHA.5808@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to save the file locally? Our ISP (Fasthosts) don't seem
to understand what we
> are asking them and keep trying to force us to use DTS to backup the datab
ase.
> We've got Microsoft SQL Server 8.0 installed but, to be honest, we're just
using this to link to 2
> databases hosted by our ISP.
> How do we create a MSSQL database locally, so that we could import the dat
a in and THEN do the All
> Tasks > Database Backup?
> Thanks
> Nath.
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1141728051.055622.165600@.z34g2000cwc.googlegroups.com...
>

Wednesday, March 7, 2012

How to creat a first DB?

Hello all,

I've Installed VS2005 and MSSQL express with it. I used to work with mssql 2003 enterprise edition where it had "Enterprise Manager" from which I could create and modify my Databases.

How do I creat a new database with MSSQL express?

I've tried to do this via visual studio 2005 "server explorer". I"m entering the "Create new SQL Server Database" dialog, I select my server's name and my new database name and I recive an error message which says "An error has occurred while estabilishing a connection to the server" and it also says that

"When connecting to SQL server 2005, this failure may be caused by the fact that under the defult settings SQL sever does not allow remote connections".

How do configure my MSSQL express to allow the remote connection?

Thanks in advance!

With the new SQL 2005 systems you need to use the new Management Studio to perform the same tasks as the Older Enterprise Manager and Query tools. With the full versions this is included, for the basic express product you can get a smaller version from the Microsoft Downloads site, Called SQL Management Studio Express.

In the case of remote connections have a look at this support article... http://support.microsoft.com/default.aspx/kb/914277

|||

How to configure SQL Server 2005 to allow remote connections

http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

|||Thanks a lot guys :)|||


Hi,

also have a look at the screencast section on my site, which will show you a walkthrough for your problem.


HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

Sunday, February 19, 2012

How to copy MSSQL DB

Hi

I'm a newbie with MSSQL. I hv MSSQL 7.0 running successfully on my notebook as a test environment & the folder is \MSSQL7\DATA. We have a production server running live. There are 2 files called recruitment.mdf & recruitment_log.ldf which resides on the server but is not in my notebook. When i copy it to my notebook, the Enterprise Mgr does not recognise it. It does not show in the database list. Why? What shld I do?? I wud appreciate step-by-step instructions. ThanksWhat do u mean "Enterprise Mgr does not recognise it"? U just copied the mdf and ldf files, or u have attached the database but still not show up at Enterprise Manager, or u even failed to attach it?|||please see the sp_attach_db and sp_detach_db system stored procedures in sql server book online. You can also do a backup and restore using the replace argument of the RESTORE DATABASE command over a blank database. The former is what I usually do. I do not think SQL 7 had the copy database wizard (that was so long ago) but if it does, stay away from it. It's a pain.

How to copy db from test server to local machine running MSSQL2000 Per.

I am in a situation where I need to get a copy of test database that is
on production server running MSSQL 2000 Standard to my local machine
running MSSQL 2000 personel. I tried to use the copy wizard where it
appears I get connected to the source server OK but when I try to
indicate the destination server which is my local machine I get errors
poping up about cannot connect to (local) etc.

I am NOT a DBA just a programmer trying to get a local test environment
up to be more productive.

LsumnlerHi,

go to the sql client network utility on sql 2000 standard and add the
IP address of the sql 2000 personal.
Try connecting first thru query Analyzer if it connects, then go try
sql wizard.

Easy way is to backup the DB on sql 2000 standard and restore on sql
2000 personal.

Let me know what happens

RA.|||"len" <lsumnler@.gmail.com> wrote in message
news:1113927630.057592.236140@.o13g2000cwo.googlegr oups.com...
>I am in a situation where I need to get a copy of test database that is
> on production server running MSSQL 2000 Standard to my local machine
> running MSSQL 2000 personel. I tried to use the copy wizard where it
> appears I get connected to the source server OK but when I try to
> indicate the destination server which is my local machine I get errors
> poping up about cannot connect to (local) etc.
> I am NOT a DBA just a programmer trying to get a local test environment
> up to be more productive.
> Lsumnler

See this KB article - there are a number of requirements for the wizard to
work correctly:

http://support.microsoft.com/defaul...kb;en-us;274463

If possible, you might find that backup/restore is an easier option:

http://support.microsoft.com/defaul...kb;en-us;314546

Simon