Tuesday, 29 March 2016

Sql Comma separated id get comma separated result using while loop


// query

declare @strQ varchar(20)='2,3,8',@cnt int=1,@strRe varchar(200)=''
while (@cnt<=LEN(@strQ))
begin
set @strRe=@strRe+cast((select ComboValue1 from TableName where Flag=9 and ComboID=SUBSTRING(@strQ,@cnt,1)) as varchar)+',';
set @cnt=@cnt+2;
end

print @strRe


// Result

Check and split string with while loop in sql


// Query

declare @strQ varchar(20)='0001010100',@cnt int=1,@strRe varchar(10)=''
while (@cnt<=13)
begin
if(SUBSTRING(@strQ,@cnt,1)=1)
begin
set @strRe=@strRe+cast(@cnt as varchar)+',';
end
set @cnt=@cnt+1;
end

print @strRe

// Result

Wednesday, 2 March 2016

Get SQL Database Table Names, Procedures, Table types and Views names



SELECT Name FROM sys.objects WHERE [Type] In ('U') -- For table Names



SELECT Name FROM sys.objects WHERE [Type] In ('V') -- For VIEWS



SELECT Name FROM sys.objects WHERE [Type] In ('PK') -- For PRIMARY_KEY_CONSTRAINT



SELECT Name FROM sys.objects WHERE [Type] In ('TT') -- For TYPE_TABLE




SELECT Name FROM sys.objects WHERE [Type] In ('P') -- SQL_STORED_PROCEDURE



Get All table name from Database in ms access



SELECT Name FROM MSysObjects WHERE

(Left([Name],1)<>"~") AND (Left([Name],4) <> "MSys") AND ([Type] In (1, 4, 6)) ORDER BY Name


                          

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...