Showing posts with label t-sql. Show all posts
Showing posts with label t-sql. Show all posts

Friday, March 30, 2012

How do i add Pubs database to Sql server 2005

Hi there,
I just want to play with Pubs data base that is available in
Management Studio and apply all the enhancements of T-SQL in SQL '05.
How would i install the PUBs and Northwind databases to the Management
Studio databases?
Thanks
-DDownload and install from MS:
http://www.microsoft.com/downloads/...&DisplayLang=en
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Learner" <pradev@.gmail.com> wrote in message
news:1139932399.753049.165860@.g47g2000cwa.googlegroups.com...
> Hi there,
> I just want to play with Pubs data base that is available in
> Management Studio and apply all the enhancements of T-SQL in SQL '05.
> How would i install the PUBs and Northwind databases to the Management
> Studio databases?
> Thanks
> -D
>|||Hi Tibor,
Yes i got the SQL2000SampleDb.msi already on to my desktop. But i
couldn't find an option to select so that i could install in Sql server
2005 rather than in Sql server 2000.
I also tried backing up the pubs data base from Sql server 2000 and
restroing it in Sql server 2005. It has thrown some error.
Do i need to set up some thing in order to forcebly install in Sql
server 2005 during the installation process of Sql2000SampleDb.msi?
Thanks
-L|||> I also tried backing up the pubs data base from Sql server 2000 and
> restroing it in Sql server 2005. It has thrown some error.
Above work, I've done that several times. But you need to provide us with mo
re information. What
errors? Did you use the MOVE option for the RESTORE command?

> Yes i got the SQL2000SampleDb.msi already on to my desktop. But i
> couldn't find an option to select so that i could install in Sql server
> 2005 rather than in Sql server 2000.
Same procedure. Just follow the readme, and adapt the steps for 2005 (like u
sing SSMS instead of
EM),
Whatever method you chose, remember that the databases will be in 80 compati
bility mode. Change
using sp_dbcmptlevel.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Learner" <pradev@.gmail.com> wrote in message
news:1139933503.450724.203960@.f14g2000cwb.googlegroups.com...
> Hi Tibor,
> Yes i got the SQL2000SampleDb.msi already on to my desktop. But i
> couldn't find an option to select so that i could install in Sql server
> 2005 rather than in Sql server 2000.
> I also tried backing up the pubs data base from Sql server 2000 and
> restroing it in Sql server 2005. It has thrown some error.
> Do i need to set up some thing in order to forcebly install in Sql
> server 2005 during the installation process of Sql2000SampleDb.msi?
> Thanks
> -L
>|||Tibor,
The mssage i got in the final step of restoration process when i
clicked on OK after the adding the pub.bak from
-Microsoft Sql Server
+80
+90
-MS Sql
- BACKUP
-pubs.bak
from Locate Backup file wizard.
The error i got was
TITLE: Microsoft SQL Server Management Studio
--
Restore failed for Server 'DEVI\SQLDM2005'. (Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?Prod...er&LinkId=20476
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: The operating system returned the error
'32(The process cannot access the file because it is being used by
another process.)' while attempting
'RestoreContainer::ValidateTargetForCrea
tion' on 'C:\Program
Files\Microsoft SQL Server\MSSQL\data\pubs.mdf'.
(Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?Prod...>
LinkId=20476
BUTTONS:
OK
--
I am not sure why it is complaining about 'its being used by another
process' I don't have it available under my server explorer.
I can send the word doc of all the snap shots that i documented during
the restoration process if you think that helps.
Thanks
-L|||How many instances of SQL Server are you running? It sounds like the MDF
you are trying to attach is already attached to another instance of SQL
Server...
"Learner" <pradev@.gmail.com> wrote in message
news:1139935089.008898.70290@.o13g2000cwo.googlegroups.com...
> Tibor,
> The mssage i got in the final step of restoration process when i
> clicked on OK after the adding the pub.bak from
> -Microsoft Sql Server
> +80
> +90
> -MS Sql
> - BACKUP
> -pubs.bak
> from Locate Backup file wizard.
> The error i got was
> TITLE: Microsoft SQL Server Management Studio
> --
> Restore failed for Server 'DEVI\SQLDM2005'. (Microsoft.SqlServer.Smo)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...er&LinkId=20476
> --
> ADDITIONAL INFORMATION:
> System.Data.SqlClient.SqlError: The operating system returned the error
> '32(The process cannot access the file because it is being used by
> another process.)' while attempting
> 'RestoreContainer::ValidateTargetForCrea
tion' on 'C:\Program
> Files\Microsoft SQL Server\MSSQL\data\pubs.mdf'.
> (Microsoft.SqlServer.Smo)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...
0&LinkId=20476
> --
> BUTTONS:
> OK
> --
> I am not sure why it is complaining about 'its being used by another
> process' I don't have it available under my server explorer.
> I can send the word doc of all the snap shots that i documented during
> the restoration process if you think that helps.
> Thanks
> -L
>|||Hello,
I have three servers registered in my Registered Servers window.
Devi (Sql server 2000)
Devi\Sqldm2005(Sql server 2005)
Devserver\Sql2005(Sql server 2005)
And i have only instance running under my Object Explorer
Devi\Sqldm2005(Sql server 2005)
I have pubs and Northwind databases by default under the server
Devi(which is sql server 2000).
But i don't have it attached it to my Object Explorer if at all that
makes any difference.
I am not sure if i am answering your question right though.
Tahanks
-D|||Look in Books Online for the syntax of sp_attach_db. You need to provide the
physical file names for
both the mdf and the ldf file.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Learner" <pradev@.gmail.com> wrote in message
news:1139936762.694587.151210@.g47g2000cwa.googlegroups.com...
> Hello,
> I have three servers registered in my Registered Servers window.
> Devi (Sql server 2000)
> Devi\Sqldm2005(Sql server 2005)
> Devserver\Sql2005(Sql server 2005)
> And i have only instance running under my Object Explorer
> Devi\Sqldm2005(Sql server 2005)
> I have pubs and Northwind databases by default under the server
> Devi(which is sql server 2000).
> But i don't have it attached it to my Object Explorer if at all that
> makes any difference.
> I am not sure if i am answering your question right though.
>
> Tahanks
> -D
>|||Tibor,
You mean i need to do it in Management Studio rather than using the
GUI wizards? I will try doing it through Management Studio.
But mean while if you are comfortable with, i just sent over word
document that i have made during the restoring process to your hotmail
account. Could you please suggest me if i did it right?
Thanks
-L|||Yes, I'm referring to write and execute the TSQL commands in stead of using
the GUI dialogs. I never
use the GUI for these things, so I can't be much help there, I'm afraid...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Learner" <pradev@.gmail.com> wrote in message
news:1139937684.832280.213070@.g47g2000cwa.googlegroups.com...
> Tibor,
> You mean i need to do it in Management Studio rather than using the
> GUI wizards? I will try doing it through Management Studio.
> But mean while if you are comfortable with, i just sent over word
> document that i have made during the restoring process to your hotmail
> account. Could you please suggest me if i did it right?
> Thanks
> -L
>sql

Friday, March 23, 2012

How could I obtain the domain name from SQL?

Dear fellows,
I would need from T-SQL job or through any friendly-user function (VB
front-end app) the aforementioned value.
With EXEC xp_cmdshell 'IPCONFIG /ALL' I get values such as HOST NAME or
IP Adress. Problem is the following: if oneself launch IPCONFIG /ALL from a
DOS session it is obtained DNS suffixes list with values hoped: domain,
Active Directory and so on. But launched from Query Analyzer due to it
returns more than a row appear as NULL value.
Does anyone know how/where it is available?
Best regards,> But launched from Query Analyzer due to it
> returns more than a row appear as NULL value.
Is this the only problem?
CREATE TABLE #foo(cmd VARCHAR(1024))
INSERT #foo EXEC master..xp_cmdshell 'IPCONFIG /ALL'
SELECT * FROM #foo WHERE cmd IS NOT NULL
DROP TABLE #foo|||Dear Aaron,
Is this the only problem?
No!
Your solution not works because of appers the line empty.
Thanks a lot for your support,
"Aaron Bertrand [SQL Server MVP]" wrote:

> Is this the only problem?
>
> CREATE TABLE #foo(cmd VARCHAR(1024))
> INSERT #foo EXEC master..xp_cmdshell 'IPCONFIG /ALL'
> SELECT * FROM #foo WHERE cmd IS NOT NULL
> DROP TABLE #foo
>
>|||> Your solution not works because of appers the line empty.
Okay, so is this really that difficult?
SELECT * FROM #foo WHERE cmd > ''

Monday, March 19, 2012

How can you get the current database name via T-SQL?

I have stored some commonly used sprocs and user-defined functions I have created in a separate db.

Some of these functions work with the current db sysobjects table, for instance, and need to "know" the database that I am calling the sproc/function from.

Is there anyway to return the current database name via T-SQL to assign to a local variable which I can then include in the procedure/function execute statement?

Bill

Use the system function: db_name().

SELECT db_name()

|||

Code Snippet

select db_name()

|||

Thanks so much. I knew is was probably simple, just couldn;t find it in the T-SQL help.

Monday, March 12, 2012

How can we check the language by which functions, stored-procedures, and triggers are written in

Hi, all here,

Could please any experts here give me any guidance in what way can we check in what language (T-SQL or CLR language?) the user defined database engine objects :functions, stored-procedures and triggers are written?

Thanks a lot in advance for any guidance and advices for that.

With best regards,

Yours sincerely,

Sys.objects provides that information

Have a look at this page in BOL ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/f8d6163a-2474-410c-a794-997639f31b3b.htm

|||

Hi, Simon,

Thanks a lot.

With best regards,

Yours sincerely

How can we check the language by which functions, stored-procedures, and triggers are writte

Hi, all here,

Could please any experts here give me any guidance in what way can we check in what language (T-SQL or CLR language?) the user defined database engine objects :functions, stored-procedures and triggers are written?

Thanks a lot in advance for any guidance and advices for that.

With best regards,

Yours sincerely,

Sys.objects provides that information

Have a look at this page in BOL ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/f8d6163a-2474-410c-a794-997639f31b3b.htm

|||

Hi, Simon,

Thanks a lot.

With best regards,

Yours sincerely