Viewing 15 posts - 781 through 795 (of 1,114 total)
Can anybody help me to achieve the same task by using SET BASED THEORY ?
April 24, 2008 at 12:57 am
Hi All,
Below one is working fine.
--------------------------------------------------------
declare @sql varchar(1000), @minid int, @maxid int,
@table_n varchar(255), @col varchar(255), @dbnm varchar(50)
Create table #tmp1
(
ID int identity(1,1),
TableName varchar(50),
ColumnName varchar(50)
)
Create table #FinalResult
(
DBName varchar(15),
TableName varchar(50),
ColumnName varchar(50),
NULL_Row_Count int,
Total int
)...
April 23, 2008 at 9:23 am
April 23, 2008 at 8:36 am
declare @str varchar(2000)
select @Nm = 'Age'
select @str = 'select count(*) from #t1 where' +@Nm +' is null'
exec (@str)
am i correct ?
If yes,How to capture the output in a variable.
April 23, 2008 at 8:33 am
Sorry for my mistake.
Please try it and let me know if there is any mistake.I hope i refined all the errors.
-----------------
CREATE PROCEDURE dbo.PAMA_UPD
...
April 23, 2008 at 8:14 am
Carl Federl
select @Nm = 'Age'
select @Null = count(*) from #t1 where (@Nm) is null
As "where (@Nm) is null" will always be false, zero rows will meet the
restriction.
...
April 23, 2008 at 8:08 am
My question is:
How do I get the result of dynamic SQL into a variable?
April 23, 2008 at 7:50 am
Actually, It is working fine. But i want to capture the exec (@sql) & exec(@sql1) results in a seperate table.
April 23, 2008 at 7:43 am
No i am not getting any error message, But the results are not getting insert into that particluar table.
April 23, 2008 at 7:42 am
Can you tell me in which part you are getting error message ?
April 23, 2008 at 7:40 am
Ryan,
Thanks for giving that URL.
I have tried out the below code:
......................................................................................................................................
--drop table #ColumnNames,#FinalResult
Select ID = IDENTITY(1,1,int),name
into #ColumnNames
From syscolumns where object_name(id) = 'Stock'
Declare @sql varchar(2000),@Sql1 varchar(2000)
Declare @min-2 int,@Max int
Declare @curColName...
April 23, 2008 at 5:13 am
Going further,
I have morethan 120 tables in a DB. I have to pass each table one by one as a parameter and i need the mentioned output.
As each and evry...
April 23, 2008 at 3:35 am
rbarryyoung,
Thanks for your reply.
But some table has more than 150 columns. So do i have to hard code it manually ? Is there any way to include the column name...
April 23, 2008 at 3:16 am
Jeff,
Below is my code:
................................................
CREATE PROCEDURE dbo.PAMA_UPD
@dMonth DATETIME,
@Pform VARCHAR(50)= '',
@MId VARCHAR(50) = ''
AS
begin
declare @StDt datetime
declare @EndDt datetime
declare @CheckDt datetime
declare @totCnt integer
declare @MStatus varchar(1)
declare...
April 23, 2008 at 3:13 am
Viewing 15 posts - 781 through 795 (of 1,114 total)