Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Tuesday, March 27, 2012

conversion to date

HI everyne,

I have a varchar field in one table, which contains data in the form '010706' and I want to convert this to date datatype to 01/07/2006 (Jan 07, 2006). When I just import the data to the other table it gets converted to 7/6/2001, how can I convert it right? Please help.

CAST(RIGHT(datafield,2)+LEFT(datafield,4) AS datetime)

|||Thanks Motley. It works!

Sunday, March 25, 2012

CONversion of an input parameter for a SP in the desired form.

hi All ,

I am getting one param for a SP as list of states from the Front End as :

@.states = 'NY,NJ,CA,Fl,MA' . Now i have to convert this param in the form :

@.states_for_SP = 'NY','NJ','CA','Fl','MA' . Is there any efficient way to do it except using REPLACE function. As this portion in our SP is taking a lot of time in converting in the desired form.

Plz suggest to do this.

Thanks.

I don't understand why a simple replace, e.g.

Code Snippet

declare @.a varchar(100)
set @.a = '''NY,NJ,CA,Fl,MA'''

declare @.b varchar(100)
set @.b = replace(@.a, ',', ''',''')

select @.a, @.b


Gives 'NY,NJ,CA,Fl,MA' > 'NY','NJ','CA','Fl','MA'

Should be slow. Is this similar to what you're trying to do?

Greg.

|||

Mohit,

This is a slightly different approach.

Using the function below you can convert the list into a table and then join the table into your query.

Code Snippet

IFEXISTS(

SELECT*FROMsys.objects

WHEREobject_id=OBJECT_ID(N'[dbo].[list2set]')

ANDtypein(N'FN', N'IF', N'TF', N'FS', N'FT')

)

DROPFUNCTION [dbo].[list2set];

GO

CREATEFUNCTION dbo.list2set( @.list nvarchar(max), @.delim nvarchar(10))

RETURNS @.resultset TABLE( pos intidentity, item nvarchar(max))

AS

BEGIN

IFlen(@.list)<1 RETURN;

DECLARE @.xList XML;

-- no validity tests are performed, depending on input this could fail

SET @.xList =Convert(XML,''+REPLACE(@.list, @.delim,'')+'')

INSERTINTO @.resultset

SELECT data.listitem.value('.','nvarchar(max)')as item

FROM @.xList.nodes('/list/item') data(listitem)

RETURN

END

GO

You'd then use it as such:

Code Snippet

SELECT adr.state

FROM Address adr

innerjoin dbo.list2set(@.states, N',') sel

on adr.state = sel.item

|||

here the code..

Code Snippet

Create Table #Numbers(

Number Int

);

Declare @.I as int;

Set @.I = 1

While @.I<100

Begin

Insert Into #Numbers values(@.I);

Set @.I = @.I + 1;

End

Declare @.states varchar(100)

Set @.states = 'NY,NJ,CA,Fl,MA'

Declare @.StatesTable Table

(

State Varchar(100)

)

Insert Into @.StatesTable

Select Substring(',' + @.states + ',', Number, CharIndex(',',',' + @.states + ',',Number) - Number)

From

#Numbers

Where

Number<=Len(',' + @.states + ',')

And Substring(',' + @.states + ',',Number-1 ,1) = ','

--As you wise for concatination..

Set @.states = ''

Select @.states = @.states + ',''' + State + '''' From @.StatesTable

Select Substring(@.states,2,8000)

--Now You can use this @.StatesTable on any query for IN operator..

--Select * From SomeTable Where States in (Select State From @.StatesTable)

Monday, March 19, 2012

Controlling the resultset size.

I'm using a report basically as a form. In this form I want the same number of lineitems no matter if I have 2 rows of data or 5 rows of data in my resultset. I basically want extra blank lines to roundout the resultset. The reason, is that with extra rows people printing the form can write additional data. Also, it will preseve the formatting. So I either need a way to tell a table in SSRS that it needs to have a minimum number of rows, OR, I need a way to add extra blank/null rows to a result set. Any ideas?

Hello,

I just developed a working solution to the same problem a few minutes ago. My problem was that the footer in the table was appearing in random places depending on the number of rows returned. I can fit 7 rows, so I needed to pad out additional rows to equal 7. So, I had to add additional data to the SQL resultset to do this. After my stored procedure produced a resultset, I immediately invoked this function to add more rows before returning to the report. Hope this helps. If anyone has an elegant solution, please post, I would like to implement it!

ALTER FUNCTION [dbo].[fCreateBlankTblRows]
(
@.nbrRows //my stored procedure figured out how many rows were returned and how many more were needed.
)

RETURNS
@.my_temp_tbl TABLE
(
id int,
id2 int,
xyx int
)
AS
BEGIN
Declare @.loopCount int;
set @.loopCount = 0;
WHILE (@.loopCount < @.nbrRows)
Begin
INSERT INTO @.my_temp_tbl
(id, id2, xyz)
VALUES (null,null,null);
set @.loopCount = @.loopCount + 1;
End;
RETURN
END

Sunday, March 11, 2012

control the percentage of processor used by SQL server

exists a form to control the percentage of processor used by SQL
server? for example, not use more than 60% percent.
I don't think you can do that.You can tell the number of cpu's to use but but
not by
percent
"hongo32" wrote:

> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>
|||"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1131739796.126120.60050@.g44g2000cwa.googlegro ups.com...
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>
First off the basic best practice is to use dedicated SQL Server boxes.
What else do you think needs CPU.
But yes, there are two tools for allocating CPU resources to SQL Server
instances: SQL Server processor affinity and Windows System Resource
Manager.
CPU affinity is configured inside SQL Server and basically allows you to
prevent a SQL Server instance from using one or more of your processors.
Windows System Resource Manager is more sophisticated and allows realtime
allocation of CPU resources to processes based on policies and server load.
So SQL Server could be allowed to use 100% of a CPU when other processes
aren't using it, but restricted to 60% when there is contention.
http://www.microsoft.com/technet/dow...srvr/wsrm.mspx
On a multi-processor system you can set the processor affinity for SQL
Server to prevent it from using some of your CPU's.
David
|||If you're on Win2003 have a look at WSRM
http://www.microsoft.com/windowsserv...m/default.mspx
For Win2k you can use Aurema ArmTech
http://www.aurema.com/products/winsql.php
We've used both and they have worked well in our environment
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1131739796.126120.60050@.g44g2000cwa.googlegro ups.com...
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>

control the percentage of processor used by SQL server

exists a form to control the percentage of processor used by SQL
server? for example, not use more than 60% percent.I don't think you can do that.You can tell the number of cpu's to use but bu
t
not by
percent
"hongo32" wrote:

> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>|||"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1131739796.126120.60050@.g44g2000cwa.googlegroups.com...
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>
First off the basic best practice is to use dedicated SQL Server boxes.
What else do you think needs CPU.
But yes, there are two tools for allocating CPU resources to SQL Server
instances: SQL Server processor affinity and Windows System Resource
Manager.
CPU affinity is configured inside SQL Server and basically allows you to
prevent a SQL Server instance from using one or more of your processors.
Windows System Resource Manager is more sophisticated and allows realtime
allocation of CPU resources to processes based on policies and server load.
So SQL Server could be allowed to use 100% of a CPU when other processes
aren't using it, but restricted to 60% when there is contention.
http://www.microsoft.com/technet/do...nsrvr/wsrm.mspx
On a multi-processor system you can set the processor affinity for SQL
Server to prevent it from using some of your CPU's.
David|||If you're on Win2003 have a look at WSRM
http://www.microsoft.com/windowsser...lt.ms
px
For Win2k you can use Aurema ArmTech
http://www.aurema.com/products/winsql.php
We've used both and they have worked well in our environment
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1131739796.126120.60050@.g44g2000cwa.googlegroups.com...
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>

control the percentage of processor used by SQL server

exists a form to control the percentage of processor used by SQL
server? for example, not use more than 60% percent.I don't think you can do that.You can tell the number of cpu's to use but but
not by
percent
"hongo32" wrote:
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>|||"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1131739796.126120.60050@.g44g2000cwa.googlegroups.com...
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>
First off the basic best practice is to use dedicated SQL Server boxes.
What else do you think needs CPU.
But yes, there are two tools for allocating CPU resources to SQL Server
instances: SQL Server processor affinity and Windows System Resource
Manager.
CPU affinity is configured inside SQL Server and basically allows you to
prevent a SQL Server instance from using one or more of your processors.
Windows System Resource Manager is more sophisticated and allows realtime
allocation of CPU resources to processes based on policies and server load.
So SQL Server could be allowed to use 100% of a CPU when other processes
aren't using it, but restricted to 60% when there is contention.
http://www.microsoft.com/technet/downloads/winsrvr/wsrm.mspx
On a multi-processor system you can set the processor affinity for SQL
Server to prevent it from using some of your CPU's.
David|||If you're on Win2003 have a look at WSRM
http://www.microsoft.com/windowsserver2003/technologies/management/wsrm/default.mspx
For Win2k you can use Aurema ArmTech
http://www.aurema.com/products/winsql.php
We've used both and they have worked well in our environment
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1131739796.126120.60050@.g44g2000cwa.googlegroups.com...
> exists a form to control the percentage of processor used by SQL
> server? for example, not use more than 60% percent.
>

Wednesday, March 7, 2012

Continuos Form/Letter

I need to create data report that has repeating rows and it is composed of
field names. This report looks like a payment book. I don't know how to do
this, because the report show me the first record but not the next 5 records.
Also, it occurs with the letters. If I have 4 customers that would receive
letters, only the first one received it(show the print preview).
I would appreciate any help.Please specify your question, i can´t get through to your problem.
Jens Suessmeyer.
--
http://www.sqlserver2005.de
--
"mlugoc" <mlugoc@.discussions.microsoft.com> schrieb im Newsbeitrag
news:E8094B21-0192-498C-8EE0-F2F243678C46@.microsoft.com...
>I need to create data report that has repeating rows and it is composed of
> field names. This report looks like a payment book. I don't know how to do
> this, because the report show me the first record but not the next 5
> records.
> Also, it occurs with the letters. If I have 4 customers that would receive
> letters, only the first one received it(show the print preview).
> I would appreciate any help.|||I want to create a payment book. Each sheet of the payment book is a fifth
part of one 8.5" x 14" (legal paper size). Each sheet has 5 coupons from
payment book. The payment book might have up to 15 coupons. My problem is
that only the first coupon of the first sheet is printed. How can I do to
print the rest of the payment book?
I examined the query and it return the correct rows.
"Jens Sü�meyer" wrote:
> Please specify your question, i can´t get through to your problem.
> Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "mlugoc" <mlugoc@.discussions.microsoft.com> schrieb im Newsbeitrag
> news:E8094B21-0192-498C-8EE0-F2F243678C46@.microsoft.com...
> >I need to create data report that has repeating rows and it is composed of
> > field names. This report looks like a payment book. I don't know how to do
> > this, because the report show me the first record but not the next 5
> > records.
> >
> > Also, it occurs with the letters. If I have 4 customers that would receive
> > letters, only the first one received it(show the print preview).
> >
> > I would appreciate any help.
>
>