SSQA.net

Knowledge Sharing Network
Welcome to SSQA.net Sign in | Join | Help
in Search

Browse by Tags

All Tags » T-SQL   (RSS)
Showing page 1 of 2 (18 total posts)
  • Fun with GO

    In this blog post, I explained different uses of GO command Here is a Fun when you use GO as object name CREATE PROCEDURE GO(    @I INT)AS    SELECT @I AS number Well. The procedure is created and let us try to execute GO 2What we see is Command(s) completed successfullyBecuase it becomes a syntax to execute a ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on September 5, 2008
  • Empty string and Default values

    Often newbies use empty string and consider it as NULL. But when an empty string is passed, it may not be stored as empty string or NULL. It actually depends on the datatype of the column Consider this exampleDECLARE @t TINYINT,@s SMALLINT,@i INT,@big BIGINT,@f FLOAT,@bit BIT, @sm SMALLMONEY,@m MONEY,@d DATETIME SELECT @t='', ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on September 2, 2008
  • Dynamic PIVOT in SQL Server 2005

    The PIVOT operator available in SQL Server 2005 is used to generate the Cross-tab results Consider this example select * from (    select Year(OrderDate) as pivot_col,e.lastname, o.OrderDate FROM northwind..Employees as e    INNER JOIN northwind..Orders as o ON (e.EmployeeID=o.EmployeeID) ) as t pivot ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on August 27, 2008
  • Common migration issues (version 2000 to 2005)

    Many users complain that some new features are not working in SQL Server 2005 when the server is migrated from SQL Server 2000 These are the common tasks that should be done to avoid some migration issues 1 Change the compatibility level to 90   EXEC sp_dbcmptlevel 'your_db_name',90  This will solve the errors that occur ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on August 12, 2008
  • Another use of GO command in SQL Server 2005

    As you all know, GO command signals the end of the batch of T-SQL statements However in SQL Server 2005, it is also used to execute set of commands for a specified number of times Consider that you want to create a table that should have hundred random integer values. You can the methods like the ones specified in ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on August 6, 2008
  • Outputting DBCC results

    Sometimes it may be useful to reuse the result of the DBCC commands. If the DBCC command resturns a resultset, it can be outputted to a table. Consider the following command DBCC useroptions It returns a single resultset. To copy the resultset to a table, you can use the following Create table #dbcc_useroptions ([set option] varchar(100), ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on July 26, 2008
  • Ordering Interger values stored in Varchar column

    I have seen many newbies asking ''How do I sort the numbers stored in varchar columns?'' Here are some methods declare @t table(data varchar(15)) insert into @tselect '6134' union allselect '144' union allselect '7345' union allselect '109812' union allselect '100074'union allselect '1290' union allselect '45764' --Method 1 select data from ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on July 21, 2008
  • Varchar(max) datatype and Replicate function

    As you know, Replicate function is used to repeat a character expression for a specified number of times. But by default the result is converted to varchar of maximum size 8000 when you dont convert the expression to specific type Consider the following example declare @v varchar(max)set @v=replicate('a',50000)select len(@v),datalength(@v) Note ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on July 15, 2008
  • Simulating undocumented Procedures

    Sometimes you may want to run a query against each database Suppose you want to find all dabase names where particular table exists. You can use undocumented procedure EXEC sp_msforeachdb 'SELECT table_catalog FROM ?.INFORMATION_SCHEMA.TABLES where table_name=''your_table'''Because they are undocmented, you cant always rely on them. ...
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on May 19, 2008
  • Object Catalog Views in SQL Server 2005

    In addition to INFORMATION_SCHEMA VIEWS, in SQL Server 2005, we can use Object Catalog Views to know more informations about the objects Refer this http://msdn.microsoft.com/en-us/library/ms189783.aspx
    Posted to SQL Server Transact-SQL (SSQA.net) (Weblog) by Madhivanan on May 3, 2008
1 2 Next >
Powered by Community Server (Commercial Edition), by Telligent Systems