Showing posts with label wrong. Show all posts
Showing posts with label wrong. Show all posts

Monday, March 26, 2012

REPLACE statement

I am running the following statement but its not updating anything. Whats
wrong.
update baandb.dbo.ttiitm012500
set t_item = REPLACE(t_item,'- get fro','')
where t_item like '%get fro%'
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200701/1ok I found my stupid error. a space in the wrong place.
ghunter wrote:
>I am running the following statement but its not updating anything. Whats
>wrong.
>update baandb.dbo.ttiitm012500
>set t_item = REPLACE(t_item,'- get fro','')
>where t_item like '%get fro%'
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200701/1

Wednesday, March 21, 2012

Replace existing table

Hi. I am new to SQL Server so please excuse me if my question is stupid or asked in the wrong place.

I am replicating a number of Visual FoxPro tables in SQL Server. The tables are updated daily. I have got several of them replicated fine through using BULK INSERT to load the existing data and INSERT/UPDATE/DELETE to replicate the daily updates.

However, one of the Visual FoxPro tables is re-created from scratch each day. I could do the same in SQL Server but I would like users to have uninterrupted access to it (i.e. I do not want a query to fail while I am deleting and then re-upsizing the table).

One method that occurs to me would be to upsize the table under a different temporary name and then BEGIN TRANSACTION, delete the old table, rename the new table to the old table and then COMMIT TRANSACTION. Would this work? And is there a better way of doing this?

Many thanks

Dom

I know the users have to go to lunch daily..., so announce a lunch break at 1 pm for all the people and do what to do; if your users don't want to leave do it after they go home.

Sure ,before take a full backup if you have time.

|||Thanks ggciubuc, but I'm afraid thats not an option. The update needs to be done as early as possible (but no earlier than 8am) so it cannot wait until the users have gone home, but it will not be at a consistent time of day because the start time depends on the time taken to complete a number of prior processes.|||

Make a Integration Services package , put it in a job that runs before 8 a.m (eg. 6 a.m); the package can contain:

1.a task that delete the SQL table

2. a task that re-create the SQL table

3. a task with bulk insert

with workflow you can prioritize the processes|||

Thanks Gigi - I have not come across Integration Services before, I will check it out.

However, as stated above, it cannot run earlier than 8am (typically it will run at some point around 10am but some days it may not be until 1pm or later) and I would like to avoid disrupting users if possible.

|||

I recommend to use your proposed solution (with minor change) for this task & (it may be done on the SSIS Package or DTS package), but your approach seems to be good enough to fit for your requirement.

1. Create a table on different temp name (not temp table -- #)

2. Do the manipulation on created table

3. On single transaction, Delete the existing row, insert from created table, drop the created table.

|||

Many thanks Manivannan, I'll give it a go. Deleting all of the the existing rows and then inserting the new records makes much more sense, I guess.

Could I even use a BULK INSERT to append the records (does BULK INSERT work inside a transaction?) and avoid creating the temporary table altogether?

|||

You can use the BULK INSERT on explicit(user) transaction. It can be roll backed also. J

Monday, February 20, 2012

RENDERSTREAM - What am I doing wrong?

I'm writing my own app that calls the RS Web Service.
So far, pretty good, but I can't seem to make RENDERSTREAM Work.
Do you have any idea what is wrong with this code?
The error I get is that RenderStream can not find the stream...
RenderedReport = myReportService.Render
(myReport, Format, HistoryID, DeviceInfo, myParameters, Credentials,
ShowHideToggle, Encoding, MimeType, UsedParameters, Warnings, StreamIDs)
For Each streamid As String In StreamIDs
RenderedStreams = myReportService.RenderStream _
(myReport, Format, streamid, Nothing, Nothing, Nothing,
Nothing, Nothing)
My DEVINFO for the RENDER is
DeviceInfo = "<DeviceInfo>"
DeviceInfo += "<HTMLFragment>True</HTMLFragment>"
DeviceInfo += "<Parameters>False</Parameters>"
DeviceInfo += "<Toolbar>False</Toolbar>"
DeviceInfo += "<StreamRoot>/" + Session("RSFolder") +
"/resources/</StreamRoot>"
DeviceInfo += "</DeviceInfo>"
Thanks.IraD wrote:
> I'm writing my own app that calls the RS Web Service.
> So far, pretty good, but I can't seem to make RENDERSTREAM Work.
> Do you have any idea what is wrong with this code?
> The error I get is that RenderStream can not find the stream...
Ira..
Try this:
Dim result As Byte() = Nothing
Dim image As Byte()
result = rs.Render(path, format, historyID, deviceInfo, parameters, Nothing,
Nothing, encoding, _
mimeType, parametersUsed, warnings, streamIds)
Select Case format
Case "HTML4.0", "HTML3.2"
' render stream for each image and save to disk
Dim stream As System.IO.FileStream
For Each streamid As String In streamIds
Dim encodingImage As String
Dim mimeTypeImage As String
image = rs.RenderStream(path, format, streamid, Nothing, Nothing,
parameters, encodingImage, mimeTypeImage)
stream = System.IO.File.OpenWrite(Server.MapPath("./Temp") & "\" &
streamid)
stream.Write(image, 0, CInt(image.Length))
stream.Close()
Next
Dim enc As System.Text.Encoding = System.Text.Encoding.UTF8
ReportPlaceholder.InnerHtml = enc.GetString(result)
Case Else
Response.ClearContent()
Response.AppendHeader("content-length", result.Length.ToString())
Response.ContentType = mimeType
Response.BinaryWrite(result)
Response.Flush()
Response.Close()
End Select|||Frank,
Much closer. My error was that I did not pass the "parameters" argument
correctly to RENDERSTREAM. I had NOTHING, now that I have sent along the
parameters, renderstream works.
But I don't understand the reportplaceholder.innerhtml statement. What I
now see on my screen is a box that looks like it wants to hold my chart - but
it doesn't have it. Do I have to send the results of renderstream to the
response object as well as the results of the render?
Thanks.
"Frank Matthiesen" wrote:
> IraD wrote:
> > I'm writing my own app that calls the RS Web Service.
> > So far, pretty good, but I can't seem to make RENDERSTREAM Work.
> >
> > Do you have any idea what is wrong with this code?
> > The error I get is that RenderStream can not find the stream...
> Ira..
> Try this:
> Dim result As Byte() = Nothing
> Dim image As Byte()
> result = rs.Render(path, format, historyID, deviceInfo, parameters, Nothing,
> Nothing, encoding, _
> mimeType, parametersUsed, warnings, streamIds)
>
> Select Case format
> Case "HTML4.0", "HTML3.2"
> ' render stream for each image and save to disk
> Dim stream As System.IO.FileStream
> For Each streamid As String In streamIds
> Dim encodingImage As String
> Dim mimeTypeImage As String
> image = rs.RenderStream(path, format, streamid, Nothing, Nothing,
> parameters, encodingImage, mimeTypeImage)
> stream = System.IO.File.OpenWrite(Server.MapPath("./Temp") & "\" &
> streamid)
> stream.Write(image, 0, CInt(image.Length))
> stream.Close()
> Next
> Dim enc As System.Text.Encoding = System.Text.Encoding.UTF8
> ReportPlaceholder.InnerHtml = enc.GetString(result)
> Case Else
> Response.ClearContent()
> Response.AppendHeader("content-length", result.Length.ToString())
> Response.ContentType = mimeType
> Response.BinaryWrite(result)
> Response.Flush()
> Response.Close()
> End Select
>
>|||IraD wrote:
> But I don't understand the reportplaceholder.innerhtml statement.
> What I
> now see on my screen is a box that looks like it wants to hold my
> chart - but it doesn't have it. Do I have to send the results of
> renderstream to the response object as well as the results of the
> render?
PlaceHolder is declared on aspx-page
Send me your mail-adress...i will send you the files with full code.
regards
Frank|||Much appreciated: IDOBROW@.AIB.ORG
"IraD" wrote:
> I'm writing my own app that calls the RS Web Service.
> So far, pretty good, but I can't seem to make RENDERSTREAM Work.
> Do you have any idea what is wrong with this code?
> The error I get is that RenderStream can not find the stream...
> RenderedReport = myReportService.Render
> (myReport, Format, HistoryID, DeviceInfo, myParameters, Credentials,
> ShowHideToggle, Encoding, MimeType, UsedParameters, Warnings, StreamIDs)
> For Each streamid As String In StreamIDs
> RenderedStreams = myReportService.RenderStream _
> (myReport, Format, streamid, Nothing, Nothing, Nothing,
> Nothing, Nothing)
> My DEVINFO for the RENDER is
> DeviceInfo = "<DeviceInfo>"
> DeviceInfo += "<HTMLFragment>True</HTMLFragment>"
> DeviceInfo += "<Parameters>False</Parameters>"
> DeviceInfo += "<Toolbar>False</Toolbar>"
> DeviceInfo += "<StreamRoot>/" + Session("RSFolder") +
> "/resources/</StreamRoot>"
> DeviceInfo += "</DeviceInfo>"
> Thanks.