Viewing 15 posts - 31 through 45 (of 47 total)
Hi,
Please check the following code. This may help you.
------code
declare @time table (id int identity (1,1),v_time time,v_date date)
insert into @time
SELECT
convert(time,CONVERT(VARCHAR(8),GETDATE(),108)) AS HourMinuteSecond,
CONVERT(VARCHAR(10),GETDATE(),101) AS DateOnly
from msdb.INFORMATION_SCHEMA.COLUMNS
update @time set v_time = DATEADD(mi,15*id,v_time),v_date...
January 17, 2011 at 11:29 pm
Try this
declare @t table (id int identity(1,1),time_stamp date)
declare @st date,@en date
select @st = '2011-01-01'
select @en = '2011-01-20'
insert into @t
select convert(varchar(10),@st,110) from INFORMATION_SCHEMA.COLUMNS
update @t set time_stamp = dateadd(day,id-4,time_stamp)
select time_stamp from...
January 3, 2011 at 11:55 pm
-- check this will resolve your solution
declare @t table (id int identity(1,1),time_stamp date)
declare @st date,@en date
select @st = '2011-01-04'
select @en = '2011-01-08'
insert into @t
select convert(varchar(10),GETDATE(),110) from INFORMATION_SCHEMA.COLUMNS
update @t set...
January 3, 2011 at 10:56 pm
Hi
declare @t table (sequence_id int,id int,name_key varchar(10),item_name int,rule_id varchar(10))
insert into @t values (1,6761,'Includes',0, NULL )
insert into @t values (2,6761,'item',160,'abc')
insert into @t values (3,6761,'item',163,'xyz')
insert into @t values (4,6761,'Requires',0,NULL)
insert into @t...
December 31, 2010 at 3:53 am
Hi Dave
I think the query is answered!!!, would you need any more explanation about those 3 lines of code.
Regards
Siva Kumar J
November 26, 2010 at 7:08 am
Hi
Check the following code. This may be useful.
declare @test_tab table (slno int,name varchar(10))
insert into @test_tab values (1,'a')
insert into @test_tab values (1,'b')
insert into @test_tab values (1,'c')
insert into @test_tab values (2,'a')
insert into...
November 26, 2010 at 6:44 am
Hi
1. SET @ColName= select function_name (@parameter)
2. Select @Result=' Select '+ @Colname +' from <my Table> '
3. execute (@Result)
Thanks
Siva Kumar
November 26, 2010 at 6:17 am
-- This can be used for your solution. But this is not a complete solution.
-- Chance for having sql injection.
CREATE PROCEDURE [dbo].[Dynamic_Query_Example] (@p_category varchar(20))
as
begin
declare @v_count int
declare @sql_query varchar(max), @p_category_select...
November 23, 2010 at 7:18 am
Hi Paul,
Thats great. Can u pls give me the best solution to come over the problem.
Thanks
Siva Kumar
October 14, 2010 at 11:30 pm
Hi
May be this one is better solution.
CREATE PROCEDURE [dbo].[Dynamic_Query_Example] (@p_category varchar(20))
as
begin
declare @v_count int
declare @sql_query varchar(max), @p_category_select varchar(max)
select @v_count = count(*) from information_schema.columns where table_name = 'test' and column_name...
October 14, 2010 at 6:27 am
Hi Paul,
What happens if I pass the value '1; DROP TABLE EMP; --' as the parameter?
--------------------------------------------------------------------------------
Here is an example.
CREATE TABLE [dbo].[test](
[id] [int] NOT NULL,
[dob] [nvarchar](max) NULL,
[test] [nvarchar](50) NULL
)
insert into test...
October 14, 2010 at 4:36 am
Hi,
Yes, definetly. You have to use dynamic query. First frame a query using the variables supplied to the procedure. Store query to a variable and then execute that using exec...
October 13, 2010 at 4:21 am
Hi
if Database wants to insert the current date, you have to create trigger on that table.
for ex:
-- sample code to generate time stamp for each row inserted
-- create sample table.
create...
September 20, 2010 at 7:50 am
Hi
You have to use analytical functions to acheive department wise top salaries. We can achieve top 1..n salaries from the following query. We have to use Dense_Rank() function . Adding...
September 9, 2010 at 7:36 am
Viewing 15 posts - 31 through 45 (of 47 total)