| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-02-10 : 07:51:19
|
| David Book writes "Based on all the reading I have done, this should not work. I did the reading trying to solve the "string" comma list when I could not get it to work.Back End: SQL 7.0Table Size (clients): Approx. 50,000 recordsTable Size(s) Joined Tables: approx. 100 Records EachFront End: Classic ASP Objective. Allow user to select multiple filter criteria, Records per page, Page Number, and Sort/UpDown Criteria.Problems.1)SQL Wont allow "comma seperated list's" in query2)Don't want to return a "HUGE" recordset to webserver, need pagingI got the paging (I'm new at this) from another tutorial. on sqlTeam/4Guys (sql team > 4 guys). Then modified it to accept multiple params. Many of which are Integers, converted to varChar, passed in as either "0", "ONE NUMBER", or a list of "numbers". This is the part that shouldn't work, but it seems to and I need to make sure I'm not missing something. I have tried it countless times and cannot get it to fail? So...Here is the procedure....(again, all params are form field entries/selections in an ASP pageCREATE PROCEDURE sp_PagedClients--created 02/07/2004 david book--modified 02/07/2004 david book--This procedure gets clients, creates a temp table, then return pages as needed. We do this to avoid sending GIANT result sets--to the web server. ( --Params @NextPage int, @RecsPerPage int, @Sort varChar(75), @UpDown varChar(50), @DealerId varChar(50), @StoreId varChar(1500), @UserNumber varChar(1500), @ClientStatus varChar(1500), @ClientCategory varChar(1500), @WebLead varChar(50), -- Y, N, or both @DateStampOne varChar(75), -- all dates passed as 1/1/2000 12:00:00 PM format @DateStampTwo varChar(75), @DateModifiedOne varChar(75), @DateModifiedTwo varChar(75), @Search varChar(100), @SearchWhat varChar(250), @SearchType varChar(250) --Search is item entered to search for, search what is the field, search type is the wildcard type )ASSET NOCOUNT ON--Create a temporary tableCREATE TABLE #TempItems( ID int IDENTITY, ContactId int, ClientLastName varchar(100), ClientFirstName varchar(100), Status int, RepFirstName varchar(100), RepLastName varchar(100), WebLead varchar(20), Make varchar(100), Model varchar(100), StoreName varchar(150), DateEntered dateTime, Source varchar(150), Modified dateTime, Category int)-- Insert the rows from upcoming select into the temp. table-- declare sql string variableDECLARE @mySQL varchar(3000)SET @mySQL = 'INSERT INTO #TempItems (ContactId, ClientLastName, ClientFirstName, Status, RepFirstName, RepLastName, 'SET @mySQL = @mySQL + ' WebLead, Make, Model, StoreName, DateEntered, Source,Modified,Category ) 'SET @mySQL = @mySQL + ' SELECT tblUserContacts.UserContactId, tblUserContacts.LastName AS ClientLastName , tblUserContacts.FirstName AS ClientFirstName,'SET @mySQL = @mySQL + ' tblUserContacts.Status, tblUsers.FirstName AS UserFirstName, tblUsers.LastName AS UserLastName , tblUserContacts.WebLead, 'SET @mySQL = @mySQL + ' tblUserContacts.Make, tblUserContacts.Model, Store.Name, tblUserContacts.DateStamp AS ClientDateStamp, SourceName.Name AS SourceName, 'SET @mySQL = @mySQL + ' tblUserContacts.Modified, tblUserContacts.Category 'SET @mySQL = @mySQL + ' FROM tblUserContacts 'SET @mySQL = @mySQL + ' INNER JOIN tblUsers ON tblUserContacts.UserNumber = tblUsers.UserNumber 'SET @mySQL = @mySQL + ' INNER JOIN tblStores AS Store ON tblUsers.Store = Store.StoreId 'SET @mySQL = @mySQL + ' LEFT JOIN tblUserSelect AS SourceName ON tblUserContacts.Source = SourceName.SelectId 'SET @mySQL = @mySQL + ' WHERE tblUserContacts.UserContactId > 0 ' SET @mySQL = @mySQL + ' AND tblUsers.DealerId = ' + convert(varChar, @DealerId) |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-02-10 : 09:31:25
|
| You can jam almost anything in to varchar...conversions are the issue...DECLARE @x int, @y datetime, @z varchar, @v sql_variantSELECT @x = 1, @y = Getdate(), @v = 123.456SELECT @z = @xSELECT @zSELECT @z = @ySELECT @z, CONVERT(varchar(25),@y)SELECT @z = @vSELECT @zBrett8-) |
 |
|
|
|
|
|