|
|
-
|
|
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......
|
|
-
|
|
How do I find out the maximum length of each column in a table?
Here is the answer
declare @sql varchar(8000), @table sysname
select @table='your_table', @sql=''
select
@sql=@sql+'select '''+@table+''' as table_name,'''+column_name+''' as column_name,
......
|
|
-
|
|
In SQL Forum one of the posters asked a question about dropping all the temporary tables
There are many ways to do this
One of the ways to to run the following code
declare @sql varchar(8000)
set @sql=''
select @sql = @sql+' drop table '+name from tempdb..sysobjects where xtype='u'
exec(@s......
|
|