|
|
-
49 Liked
| 46 Learned
| 31 Comments
|
|
Suppose you have a huge table which has say 30-40 columns and you want to select all of them or most of them say around 30 columns. It is a tedious job to type each of the column names. Here is a quick way to get a comma separated list of all the column......
|
|
-
|
|
There's no way to return a resultset and set variables using a single SELECT statement.
But there's one way to do it using a MERGE statement.
It's quite simple, you first declare a variable table which will be used to store some data.
You then use a ME...
|
|
-
|
|
Found another good reason to avoid using IN clause in your TSQL Queries. See the example below:
create table #temp
(
a int ,
)
create table #temp1
(
b int ,
)
INSERT #temp VALUES(1)
INSERT #temp VALUES(2)
INSERT #temp1 VA...
|
|
-
58 Liked
| 55 Learned
| 18 Comments
|
|
Suppose you have three tables named test1,test2 and test3 and you want to drop all these three, you can do it in a single DROP statement
[code]DROP table test1,test2,test3[/code]......
|
|
-
21 Liked
| 11 Learned
| 17 Comments
|
|
I just stumbled across a weird misconception that I'd like to help you to avoid:
If you consume the results of a (non-inline) table valued function, the results are not in the same order as if you take the content óf the TVF in your query.
So, if you h...
|
|
-
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...
|
|
-
10 Liked
| 8 Learned
| 16 Comments
|
|
You can use xp_cmdshell to call a bat file from SQL Server, below are the scripts for that
-- Calling batch file from SQL Server, this is batch file without parameter
[code]
EXEC MASTER..XP_CMDSHELL 'C:\SAMPLEBATFILE.BAT'
[/code]......
|
|
-
11 Liked
| 8 Learned
| 14 Comments
|
|
GO command is not only a batch seperator but also acts as while loop starting from version 2005.Run this code and see the output
[code]
select 1
Go 5
[/code]......
|
|
-
|
|
Today i studied an interesting thing related to GO statment
See in the following queries executed .***The batch preceding GO will execute the specified number of times***.
create table test( id int not null identity (1, 1) primary key)
go
...
|
|
-
|
|
It's quite old, but new for me. Great method to parse string is using of recursive CTE, as showed in Table Function:
CREATE FUNCTION fn_SplitString(@str NVARCHAR(MAX), @sep NVARCHAR(MAX))
RETURNS TABLE
AS
RETURN
(
WITH sepPos ...
|
|