Auto generating data retrieval SP will be done by just a second… set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go CREATE procedure [dbo].[SelectSP] ( @tablename varchar(100)) as declare @cname varchar(100), @strAllColumns varchar(5000) declare crsColumn cursor for select name from syscolumns where id=object_id(@tablename) ———————————————————————- begin ———————————————————————- —————————————- Header Information ———- print ‘/* Procedure Name : usp’ […]
Archive for August, 2008
Generating Auto generated SELECT SQL from Oracle Database
Posted by: abu | August 27, 2008 | No Comment |set pagesize 2000 set linesize 2000 set long 4000 –create table gensql(line number(4) not null primary key,txt varchar2(4000)) delete gensql / commit / declare cursor cl is select ‘CREATE TABLE ‘||TABLE_NAME||’ ( ‘ tbl, column_name clmn, SUBSTR(decode(data_type,’VARCHAR2′,’VARCHAR2(‘||TO_CHAR(DATA_LENGTH)||’)’, ‘CHAR’,’CHAR(‘||TO_CHAR(DATA_LENGTH)||’)’, ‘NUMBER’, DECODE(DATA_PRECISION, NULL, ‘NUMBER’, ‘NUMBER(‘||TO_CHAR(DATA_PRECISION)||’,’||TO_CHAR(DATA_SCALE)||’)’), ‘DATE’,’DATE’),1,14) data_type, decode(nullable, ‘N’, ‘Not Null’, null) null_stat from cols where […]
In a project if we have 50 tables, and average 10-15 columns then to write stored procedure for insert and update we have to take average 30 minutes each, then more than 25 hours will be required for only data insert/update operaion. This will be very difficult job… typing table name, column name we will […]
Splitting comma separated IDs into one by one using T-SQL
Posted by: abu | August 26, 2008 | 1 Comment |declare @str varchar(200)declare @chr char(1)declare @val numericdeclare @cnt numericset @cnt = 0set @str = ‘1,22,11,0,5’if right(@str,1)<>‘,’ begin set @str = @str+‘,’endset @val = (len(@str) – len(replace(@str,‘,’,”)))while @cnt < @valbegin print substring(@str,1,patindex(‘%,%’,@str)- 1) set @str = substring(@str,patindex(‘%,%’,@str) + 1,len(@str) – patindex(‘%,%’,@str)) set @cnt = @cnt + 1end In some cases we need to manipulate data […]
I am planning to buy iPhone. Today I am googling to know the best selling price in India in terms of INR. After reading the article, I am totally confused about the possible price…. IPhone, at what price?http://computing.in.msn.com/gadgets/article.aspx?cp-documentid=1614145