Showing posts with label dynanic. Show all posts
Showing posts with label dynanic. Show all posts

Wednesday, March 21, 2012

Dynanic table creation

Hello friends
I want to have a trigger for creating table on dialy basis.
for e.g. I have a table say Data and on each day a new table is created like Data24Oct05 and so on.
please help for writing the trigger for the same.
thanks
This seems like a job for SQL Server Agent, not a trigger. I'dwrite a stored procedure to create the table, and schedule it via SQLServer Agent to run every day.
|||

Thank you very much.....
Could you please tell me how should I create dynamic table in the query? like, I have to append the today's date to a fixed string and create the table for that name.
And also where how to set the schedule for running this stored proc at the end of the day?

Please reply back

|||

swatib wrote:

Thank you very much.....
Couldyou please tell me how should I create dynamic table in the query?like, I have to append the today's date to a fixed string andcreate the table for that name.
And also where how to set the schedule for running this stored proc at the end of the day?

Please reply back


Your dynamic CREATE TABLE statement would look something like this:
DECLARE @.Sql varchar(200)
SELECT @.Sql = 'CREATE TABLE Data' + REPLACE(CONVERT(char(12),GETDATE(),113),' ','') + '(column1 varchar(10), column2 int)'
EXECUTE(@.Sql)

And you can use Enterprise Manager to access SQL Server Agent toschedule the job. Click on your server name, then chooseManagement. Under that, click on SQL Server Agent. Underthat, right-click on Jobs and choose New Job. Enter the nameyou'd like to call this job, enter a T-SQL step to EXECUTE your storedprocedure, and set the Schedule.

|||Thank you very much sir for the details reply and the solution.

dynanic report with checkbox control

hi all ,
(Using C#.net) there are 4 fields (name , family name , ave , stNumber )in my table . for this , in my form(form1) I've 4 CheckBox Controls . I want to take a report whenever the user select one or two or ... of them . for example , if the user checked CheckBox1(for the name field ) and CheckBox2(for the family field) , In outpout report show , name and family . how can i dot with crystal report ?
plz help me .In Form1 I've a checkbox control . I created a parameter in crystal report .
this is my code :
in btnReport_Click :

{
string strQuery = "SELECT Name FROM MyTable";
sqlconn.Open();
daAdapter = new SqlDataAdapter(strQuery, sqlconn);
SqlCommandBuilder scb = new SqlCommandBuilder(daAdapter);
da.Fill(DatatSet1.MyTable);
//Definitions
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
//setting
paramfield.Name = "Name";
discreteval.Value = ??
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
crystalReportViewer1.ParameterFieldInfo = paramfields;crystalReportViewer1.ReportSource = crystalreport1;
sqlconn.Close();}

I want to take a report from all of records' Name field of the Table When The user checked "CheckBox1" Control .
plz help me in this :
discreteval.Value = ??
thanx|||You can use global variables

Public gblnShowName As Boolean

In Command button Sub, set the value

If chkShowName.Value = vbChecked Then
gblnShowName = True
Else
gblnShowName = False
End If

Then inside the report code section,

If gblnShowName = True Then
Report.NameField.Suppress = False
Else
Report.NameField.Suppress = True
End If

I normally code like this in VB6, hope it works in .NET also.|||hi,
It doesn't work .|||at last it was solved .
in report sheet , right click on any field , and select Format Object and then checked on suppress CheckBox . after that , in Form1.cs , in btnShowReport_Click , write this :
myCrystalReport1.ReportDefinition.Sections[2].ReportObjects["firstname1"].ObjectFormat.EnableSuppress = false;