
SQL DBA
Sql Database realted question and answer.
This site is created by Ajit kumar and Naveen kumar, working with MNC from past 6 years supporting fortune 500 companies. This site is a free service and provide solutions to most of the subject like UNIX, WINDOWS, JAVA, C++, C, PERL, SAP, ORACLE, SQL.
All Friends
Can some one help me how to create a database in SQL 2005 and also how to see how many database are created and i am using which database.
Thanks in Advance
Guru
I am dividing your question in multiple questions and answer them one by one.
Q1) How to create database(D in SQL 2005.
A) You can create DB in two ways
i. Management studio -> In object Explorer, expand your server name-> Databases -> Right click and select New Database
ii. Query Analyser -> CREATE DATABASE MYDATABASENAME
Q2) How many DB's
A) Visually from Management Studio and from Query analyser -> select * from sys.databases
Q3) Db in use
A)select DB_NAME()
Answered By Mr Ajit Kumar from Value Labs
I want to import all database names into my SQL Server using a query
Can some one help me with the query?
Thank
sanjay patil
Hi,
My understanding of the question: You want to get the list of databases on another server B and insert into a table on your server A
Soln: 1. Link both the servers, i.e Link Server B from Server A, using GUI or Sp_Addlinkserver
If your Link name is [remSrvr]
Now use fully qualified name to query
select * from remSrvr.master.sys.databases
now if you insert the data into any table, then
select * into myDBlist from remSrvr.master.sys.databases
Useful information in sql 2005 -
One of new features in SQL 2005 that I haven't seen much talk about is that you can now add aggregate functions to any SELECT (even without a GROUP BY clause) by specifying an OVER() partition for each function. Unfortunately, it isn't especially powerful, and you can't do running totals with it, but it does help you make your code a little shorter and in many cases it might be just what you need.
Regards
SQL Experts