|
|
-
|
|
One of the questions asked in a forum was about replacing data of one table by the data of
another table
The solution that the questioner used was having cursor by looping through the source table and
replace particular words by other words from another table by matching the words
Here is ......
|
|
-
|
|
In the Query Analyser, set the Result mode to Text (Press CTRL+T) and run the following code
set nocount on
select
space(17-len(replicate(char(94),no)))+ replicate(char(94),no*2-1)
from
(
select top 10 row_number() over (order by name) as no from sysobjec......
|
|
-
|
|
Sometimes, you may need to find a value in the characters columns (char, varchar, etc) in all
the tables
This is one of the methods to do it
declare @sql varchar(max),@search varchar(100)
set @sql=''
set @search='your search string'
select
@sql=@sql+'select distinct ''['+c......
|
|
-
|
|
In my previous post about Removing unwanted characters , I posted a method that used a function
Here is another method that uses Dynamic SQL
declare @data table (data varchar(100))
-- table that has source data
insert @data
select 'tes^@&t %stri)-n!g' data union all
select '))aa......
|
|
-
|
|
0
begin
insert into @temp(data)
select substring(@s,1,charindex('~!@#',@s)-1)
set @s=substring(@s,charindex('~!@#',@s)+4,len(@s))
end
insert into @temp(data)
select @s
--Extract the tags
select data from @temp where id%2=0
--Extract the data available outs......
|
|
-
|
|
As you know, semicolon is used as a statement terminator in almost all RDBMSs. However the usage
of semicolon is optional in SQL Server except a few cases. Here are atleast the three cases
where usage of semicolon is a must
1 At the start of the Common Table Expression (If any statement prece......
|
|
-
|
|
One of the new features available in SQL Server 2008 is compressed backup which takes backup of
a database with mimimum possible size. The syntax is
backup database db_name to disk='backup_path'
with init, compression
But this works only in Enterprise Edition of the SQL Server 2008 and not......
|
|
|
|
-
|
|
Suppose you want to import data from a text file to a table, one of the options is to use Bulk
Insert command
It allows to import data to the table, though one/more columns don't have enough size to get the
maximum length of data from text file.It throws errors about data truncation with line......
|
|
-
|
|
In http://ask.sqlteam.com, a question was asked about removing the comments from the HTML
template
The comments have the following pattern
{/*}comment{*/}
The comments can be nested too
The task is to remove all the comments
Here is my solution
declare @string varchar(8000) ,@d......
|
|