Ms Sql Server Fundamentals
Thursday, March 31, 2016
Generate Sequence number in column
1st Way
alter
table
Example
add
NewColumn
int
identity
(
1
,
1
)
2nd Way
DECLARE
@id
INT
SET
@id
=
0
UPDATE
accounts2
SET
@id
=
id
=
@id
+
1
GO
Monday, March 28, 2016
Comma Separated string into individual rows
SELECT
A
.
[State]
,
Split
.
a
.
value
(
'.'
,
'VARCHAR(100)'
)
AS
String
FROM
(
SELECT
[State]
,
CAST
(
'<M>'
+
REPLACE
(
[City]
,
','
,
'</M><M>'
)
+
'</M>'
AS
XML
)
AS
String
FROM
TableA
)
AS
A
CROSS
APPLY
String
.
nodes
(
'/M'
)
AS
Split
(
a
);
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)
Subscribe To My Blog
Posts
Atom
Posts
All Comments
Atom
All Comments
Readers
My Blog List
LEARN WITH US
.NET Fundamentals
Categories
Case When Statement
(2)
CMD
(1)
Database Email
(1)
DatePart
(1)
Definitions
(37)
ERROR
(1)
Functions
(11)
INDEXING
(2)
LINQ
(1)
Search
(1)
Smo
(3)
Split Function
(2)
SSRS
(2)
System Stored Procedure
(4)
Transaction
(1)
Wildcard
(1)
XML
(3)
Blog Archive
▼
2016
(8)
►
May
(2)
►
April
(2)
▼
March
(2)
Generate Sequence number in column
Comma Separated string into individual rows
►
January
(2)
►
2015
(2)
►
December
(2)
►
2013
(3)
►
February
(3)
►
2012
(21)
►
October
(1)
►
July
(8)
►
June
(1)
►
May
(4)
►
April
(2)
►
February
(1)
►
January
(4)
►
2011
(5)
►
December
(2)
►
November
(2)
►
October
(1)
►
2010
(18)
►
December
(1)
►
October
(2)
►
July
(3)
►
March
(5)
►
February
(2)
►
January
(5)
►
2009
(49)
►
December
(1)
►
May
(1)
►
April
(47)
Popular Posts
Handling special characters with FOR XML PATH('')
Issue: Length of LOB data to be replicated exceeds configured maximum 65536
SSRS Prompt for username and password in IE
Start with SMO
To generate insert statement for user defined tables available in SQL Server