|
|
-
|
|
When I viewed the code written by co-worker, I found this. To find sales made in 2009, the where clause was written as
[code]
Where year(sales_date)=2009
[/code]
But beware that this will not make use of index available on sales_date column. The ef......
|
|
-
|
|
I just learned one new thing today "how to get comma separated value(CSV) for every column name in tables with COALESCE function." check out following query.
[code]
Use yourdbname
Go
DECLARE @listStr VARCHAR(MAX)
SELECT @listStr = COALESCE(@listS......
|
|
-
|
|
Just learned from Pinal's blog that Try_parse() and parse() functions are CLR functions and it will throw an error if CLR is not installed. Both these functions can be converted from string to numerics/datetime. These will give better performance compar......
|
|
-
14 Liked
| 11 Learned
| 2 Comments
|
|
Many people believe that table variables are stored in memory (RAM) and temp tables are stored in tempdb. I can see a few comments around this post. (http://beyondrelational.com/justlearned/posts/262/sql-server-difference-between-temp-table-and-table-va......
|
|
-
13 Liked
| 13 Learned
| 16 Comments
|
|
Hi,
Just now i Wrote one query to remove special characters from a string..
Hope this is useful.
DECLARE @I VARCHAR(100)
SELECT @I ='abhi *s d ^.l'
WHILE PATINDEX('%[^A-Za-z0-9 ]%' , @I ) <> 0
BEGIN
SELECT @I= STUFF(@I,PATIN...
|
|
-
13 Liked
| 10 Learned
| 9 Comments
|
|
Sometimes when SQL Server is configured to use some port other than default port number (1433), then you may not be able to connect directly in SSMS just by specifying the name of the server in the **Server Name** field in **Connection to Server** dialo...
|
|
-
13 Liked
| 12 Learned
| 1 Comments
|
|
sysname is a special datatype and by default it does not allow NULL, you need to explicitly add NULL in table definition to allow null. sysname is defined as
nvarchar(128) not null
Below code will give error
declare @t1 table ( c1 int, c2 sy...
|
|
-
13 Liked
| 12 Learned
| 1 Comments
|
|
With help of below query we can quickly find the node on which sql is currently running. This is useful in clustered environments.
Select serverproperty('ComputerNamePhysicalNetBIOS')...
|
|
-
|
|
I usually take a backup and restore it when I need to move a database to another server/location. Just learned from Pinal's blog that SSMS offers a "copy database" option which allows you to copy or move a database from one location to another.
To star......
|
|
-
|
|
Just learned from Pinal's blog about right align the numeric value in output pane of SSMS.
Go to Tools -> Options -> Query Results -> Results to Text, Check the checkbox, "Right align numeric values"
Once this setting has been done, when the query is...
|
|