Script(s)

technology as-is

September 24, 2008
by gchandra
1 Comment

SQL Server Format Number – Function

This is simple function which can format a given number as Comma delimited number. ex : 98712345 as 98,712,345 Thanks to http://siccolo.blogspot.com/ (Attached is the original code which works on SQL Server 2000 and SQL Server 2005.) (download) formatnumber I … Continue reading

June 11, 2008
by gchandra
8 Comments

How to Save Column Names with Results : SQL Server 2005

Whether you are copying query output from SQL Server Management Studio or Saving result as .csv file, if you need to save the column name or column header along with result.. here is simple option you have to enable. Goto … Continue reading

June 11, 2008
by gchandra
0 comments

How to Save Query results as .CSV or Excel file using SQLServer 2005 Studio

Here is the simple way to save query results as .csv or .xls  file using SqlServer Management Studio. Execute your query Example : Select * from AdventureWorks.Person.Address Right Click on Left top corner Select “Save Result As” to save as … Continue reading

February 28, 2008
by gchandra
0 comments

How to Query Active Directory using LDAP in SQL Server 2000 / 2005 ?

Step 1:- Add a linked server for the Active Directory exec sp_addlinkedserver ‘ADSI’, ‘Active Directory Services 2.5’, ‘ADsDSOObject’, ‘adsdatasource’ Step 2 :- Then follow the steps mentioned here for setting up permissions. Step 3 :- You can query the Active … Continue reading

February 18, 2008
by gchandra
0 comments

SQL Server 2005 : Access Tables / Entities across Servers.

Accessing objects (tables..) across servers (SQL Server) is very simple. Step 1: Create a link between two servers Goto Query Window [sourcecode language=’sql’] EXEC sp_addlinkedserver    ‘PRODSVR’,    N’SQL Server’ GO[/sourcecode] ‘PRODSVR’  is the name of the Server.Execute it. Step … Continue reading

February 18, 2008
by gchandra
0 comments

SQL Server, Clean your Database Records and reset Identity Columns, The Shortest Path

(Copied from Moses’s Blog for my reference) Well, I had a small issue regarding writing a script to clean a database we have and reset its identity columns in all tables. Although the database wasn’t huge one (less than 100 tables) … Continue reading