Showing posts with label table1. Show all posts
Showing posts with label table1. Show all posts

Monday, March 12, 2012

paging mr smarty pants!

Hi, I am new to SQL server and I have what I think is probably an easy question. I have table1 that has a long var char and a unique ID. I want to create another table (table2) that has a matching unique ID for the first table and then column(s) of data that defines how the long var char should get sliced up into fields. Then I want a way (stored procedure?) to read the data out of table1, apply the structure/definition from table2 and insert it into a third table. I need to do it quickly and efficiently of course, but I dont know where to start!

So, to put it simply, heres table1:
1|pam,mitchell,female,28,hotty<lf>
2|doug,roberts,male,50,jerk<lf>

How do I store the data definition in table2 and then how do I apply it and insert the translated records to table3 to get this:
pam|mitchel|female|28|hotty
doug|roberts|male|50|jerk

I know I rambled on with this and probably could have explained better, but the white out on my screen keeps slowing me down :]

Thanks ahead of time!Come on! Somebody help me pleaseeeeeeee!!!!

Originally posted by CuteSmartChic
Hi, I am new to SQL server and I have what I think is probably an easy question. I have table1 that has a long var char and a unique ID. I want to create another table (table2) that has a matching unique ID for the first table and then column(s) of data that defines how the long var char should get sliced up into fields. Then I want a way (stored procedure?) to read the data out of table1, apply the structure/definition from table2 and insert it into a third table. I need to do it quickly and efficiently of course, but I dont know where to start!

So, to put it simply, heres table1:
1|pam,mitchell,female,28,hotty<lf>
2|doug,roberts,male,50,jerk<lf>

How do I store the data definition in table2 and then how do I apply it and insert the translated records to table3 to get this:
pam|mitchel|female|28|hotty
doug|roberts|male|50|jerk

I know I rambled on with this and probably could have explained better, but the white out on my screen keeps slowing me down :]

Thanks ahead of time!|||Create a SP, read the records one by one using cursor, and then parse the string by the format definition.
Anotherway is to dump the data into a text file and import them by DTS.|||uh cutesmartchic?

since you are trying to get help based on how cute you are, ill gladly help you.

WHEN I SEE YOUR PICTURE!!

ps- im a sql developer, 4 years|||If you're only doing this once, using enterprise manager, right click on table1, export the data to table 2, right click on table 2 and go into proporties and change any field you like. When using the import/export feature on enterprise manager, you can save it as a DTS package which can be run later. Hope this helps. Bernie B.

Paging large Results in SQL 2005

lets say we have more than 100 000 rows in Table1, and we want to view each 10 rows alone... and by pressing on a NEXT button we will see the other 10 pages...

there is 2 buttons : NEXT and PREVIOUS

so can anyone tell me how to do that in SQL 2005, and what is correctly called.

I have found a code that does use ROW_NUMBER in order to view results between 2 numbers,

example: rows between 10 and 50...
but It is not what I want, so please I need some help, thank you

By Uncle SamIf you code this by program, you can use ADO object that contains "PageSize" property to set how many records could be shown in a page.|||you can do some trick with the NTILE function to get the result. though it wont perform good. also with NTILE function you need back calculate the number of pages if 10 rows per page is to be displayed....

select * from (select *,ntile(2) over(order by COL1) as PgNo from test) as TempTbl where TempTbl.PgNo = 2|||Ok can you tell me how to do that, because I am beginner|||+1 : bad idea to solve this issue using cursor or any other server-side trick. You must manage that in your client-side...|||ok but is there any Stored procedure that does it|||Order your result set by a primary (natural) key. Write your NEXT procedure to take a starting key and a requested record count and return that number of records starting at that point in the result set. Your application just needs to know that last pkey it received in order to request the next page. Similar logic works for PREVIOUS recordsets.|||okay but please can you write for me the code, because I am still a beginner and this is my project. Thank you so much|||Are you doing your project for free? Because I generally charge something for my services...

I encourage you to either hire a dba to help you, or learn advanced SQL real fast.|||sorry but I can't afford paying an advice|||You're not asking for advice. You are asking for somebody to do the work for you.

Paging large Results in SQL 2005

lets say we have more than 100 000 rows in Table1, and we want to view each 10 rows alone.... and by pressing on a NEXT button we will see the other 10 pages....

there is 2 buttons : NEXT and PREVIOUS

so can anyone tell me how to do that in SQL 2005, and what is correctly called.

I have found a code that does use ROW_NUMBER in order to view results between 2 numbers,

example: rows between 10 and 50....
but It is not what I want, so please I need some help, thank you

By Uncle Sam

You can use the ROW_NUMBER approach to page through results. You need to vary the row number ranges depending on the page. The other approach is to use TOP logic. Please take a look at the link below for the various techniques.

http://www.aspfaq.com/show.asp?id=2120

|||

Well I've been through that problem.. not only 100 000 rows but more than 1 000 000 records with multiple table lookup.. I've try every methods available on web and I found out the solution by combining all ideas.. You can look at my blog in this link and if you have any questions just email me..

http://weblogs.sqlteam.com/randyp/archive/2005/06/23/6335.aspx

|||okay but is there any creation for a button NEXT that jumps to the next page of the results.