Virtual Links In Database
Aug 13, 2007
Not sure where to place this question...
We have a bunch of SQL databases that are used for a similar number of IIS sites (we are talking of close to 500 sites), dealing with a .NET e-learning application
While we manage to create a virtual folder for the e-learning content, we do have one database for each site. So, when it comes to update the whole platform, we are talking about running one script per site, which may take about 5 seconds per user per site. With a total of 300.000 users and sites, it may come to more than 17 days running the update script.
Is there a way similar to that on IIS to create a symbolic link from one table in one database to another table in a diferent database in a diferent or same server?
Thanks,
AG
View 5 Replies
Jul 6, 2007
I have a Summary page on a report and then a detail page. FOr eg on the summary pg, I have a field called 'Name'. eg summary will be on name ie 'A', B, C ETC.. When the user clicks on the summary name ie A, he should be able to directly go to that details for that particular name ie details of 'A'.
How can I achieve this, will be probably thr parameters, but not sure how.
View 6 Replies
View Related
Oct 26, 2005
I have a problem with copying data over a db-link. When running the transaction in Query Analyzer it works fine, but when running it via a package, I get the following error-message. Has anyone a solution to this problem ???
Server: Msg 7391, Level 16, State 1, Line 3
The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionJoin::JoinTransaction returned 0x8004d00a].
View 2 Replies
View Related
Jun 6, 2008
I have been informed that all my keyword search solutions are susceptible to SQL injection attacks. Does anyone have links discussing basic ' multiple ' keyword search solutions? I would think this is a very common routine (perhaps so much so than only newbies like myself do not know it). I have read the posts about escaping ', doing replace " ' ", " '' ", using parameters and yet every multiple keyword solution I come up with is said to be injection prone.
Example: visitor enters: Tom's antiquesinto a TextBox control and the C# code behind securely generates the below call to the database.
SELECT L_Name, L_City, L_State, L_Display FROM tblCompanies WHERE L_Kwords LIKE '%' + 'Tom's' + '%' AND L_Kwords LIKE '%' + 'antiques' + '%' AND L_Display = 1 RETURN
I understand that concantenting string parts using an array and then passing the sewn together string to a stored procedure exposes it to injection. I hope that my single keyword routine below is secure, if it is not then I am not understanding how parameterized SP are supposed to be constructed to protect against injection.string CompanyName;CompanyName = TextBox1.Text;PROCEDURE CoNameSearch @CompanyName varchar(100)AS SELECT DISTINCT L_Name, L_Phone, L_City, L_State, L_Zip, L_Enabled, L_Display FROM tblLinksWHERE (L_Name LIKE @CompanyName + '%') AND L_Enabled = 1 AND L_Display = 1 ORDER BY L_NameRETURN
View 5 Replies
View Related
Apr 15, 2006
This post is to provide information and Script Library links related to datetime. There are also links to other resources.
List of Subjects
Typical Date Query
Uses of the DATETIME data type
Finding the Start of Time Periods
Finding the End of Time Periods
Generating Date Tables
Getting Time Only from DateTime
Finding Age
Finding ISO Weeks
Converting Year, Month, and Day to DateTime
Converting to/from UNIX Time
Finding the midpoint between two datetimes
Generating Random Datetimes
Creating a Formatted Calendar
Links to other Date, Time, and Calendar Resources
Typical Date Query
How to query a table with a selection on a datetime column, for example, find all items for the date 2006-01-14. This isn’t really a script, but it is one of the most common questions about datetime.
Select
*
from
NyTable
Where
MyDateColumn >= '20060114' and
MyDateColumn < '20060115'
Notice that you are asking for greater than or equal to the beginning of the date, and less than the following date. You can apply the same general query for any range of days. This is almost always the best way to write a query of this type, because it allows SQL Server to use any index that exists on the datetime column, and it uses less resources than a query that applies a function to the datetime column.
Notice that the query dates are in format YYYYMMDD; you should always use this format for date strings. This is SQL Servers "universal" date format that works the same with all settings of DATEFIRST. Any other format may produce an error if the setting of DATEFIRST is not exactly what you expect.
For datetime strings use universal format
YYYYMMDD HH:MM:SS.MIL (20061231 23:59:59.997).
Uses of the DATETIME data type
The DATETIME data type can be used to hold four different types of date/time values:
1. Date and time – a date and time together
Example: 2006-07-15 12:06:15.333
2. Date – a date only stored as the time at midnight:
Example: 2006-07-15 00:00:00.000
3. Time – a time only stored as time on the DATETIME zero date, 1900-01-01.
Example: 1900-01-01 12:06:15.333
4. Elapsed time – a difference between two DATETIME values, stored as the time since the DATETIME zero point, 1900-01-01 00:00:00.000.
Example: 1900-01-03 14:12:34.443
The actual usage of the value is only defined in the context of the application. There is no way to specify that a DATETIME is to be used for a date and time, date only, time only, or elapsed time. It is possible to insure that a column in a table contains date only or time only by adding a constraint to a column, but is is necessary that the application format the DATETIME value properly.
The following script briefly demonstrates the four different ways to use DATETIME, and several conversions from one type to another: date and time to date only, date and time to time only, date only plus time only to date and time, two date and time values to elapsed time, and elapsed time to individual days, hours, minutes, seconds, and milliseconds.
-- Demo four uses of DATETIME datatype
declare @datetime1 datetime
declare @datetime2 datetime
declare @date_only datetime
declare @time_only datetime
declare @date_plus_time datetime
declare @elapsed_time datetime
declare @elapsed_days int
declare @elapsed_hours int
declare @elapsed_minutes int
declare @elapsed_seconds int
declare @elapsed_milliseconds int
-- Load 2 datetime values
select @datetime1 = '20060715 12:06:15.333'
select @datetime2 = '20060718 02:18:49.777'
-- Get date only from datetime using DATEAADD/DATEDIFF functions
select @date_only = dateadd(day,datediff(day,0,@datetime1),0)
-- Get time only from datetime by subtracting date only
select @time_only = @datetime2-dateadd(day,datediff(day,0,@datetime2),0)
-- Add date only and time only together
select @date_plus_time = @date_only+@time_only
-- Get elapsed time as the difference between 2 datetimes
select @elapsed_time = @datetime2-@datetime1
-- Get elapsed time parts as time since 1900-01-01 00:00:00.000
select @elapsed_days = datediff(day,0,@elapsed_time)
select @elapsed_hours = datepart(hour,@elapsed_time)
select @elapsed_minutes = datepart(minute,@elapsed_time)
select @elapsed_seconds = datepart(second,@elapsed_time)
select @elapsed_milliseconds = datepart(millisecond,@elapsed_time)
declare @cr varchar(4), @cr2 varchar(4)
select @cr = char(13)+Char(10)
select @cr2 = @cr+@cr
print'Results:'+@cr2
print'Datetime1 = '+convert(varchar(30),@datetime1,121)+@cr+
'Datetime2 = '+convert(varchar(30),@datetime2,121)+@cr2
print'Date Only = '+convert(varchar(30),@date_only,121)+
', from Datetime1 = '+convert(varchar(30),@datetime1,121)+@cr2
print'Time Only = '+convert(varchar(30),@time_only,121)+
', from Datetime2 = '+convert(varchar(30),@datetime2,121)+@cr2
print'Add date and time: '+convert(varchar(30),@date_plus_time,121)+' ='+@cr+
' '+convert(varchar(30),@date_only,121)+
' + '+convert(varchar(30),@time_only,121)+@cr2
print'Elapsed Time: '+convert(varchar(30),@elapsed_time,121)+' ='+@cr+
' '+convert(varchar(30),@datetime2,121)+
' - '+convert(varchar(30),@datetime1,121)+@cr2
print'Elapsed Time Parts:'+@cr+
' Days = '+convert(varchar(20),@elapsed_days)+@cr+
' Hours = '+convert(varchar(20),@elapsed_hours)+@cr+
' Minutess = '+convert(varchar(20),@elapsed_minutes)+@cr+
' Secondss = '+convert(varchar(20),@elapsed_seconds)+@cr+
' Milliseconds = '+convert(varchar(20), @elapsed_milliseconds)+@cr2+@cr2Results:
Datetime1 = 2006-07-15 12:06:15.333
Datetime2 = 2006-07-18 02:18:49.777
Date Only = 2006-07-15 00:00:00.000, from Datetime1 = 2006-07-15 12:06:15.333
Time Only = 1900-01-01 02:18:49.777, from Datetime2 = 2006-07-18 02:18:49.777
Add date and time: 2006-07-15 02:18:49.777 =
2006-07-15 00:00:00.000 + 1900-01-01 02:18:49.777
Elapsed Time: 1900-01-03 14:12:34.443 =
2006-07-18 02:18:49.777 - 2006-07-15 12:06:15.333
Elapsed Time Parts:
Days = 2
Hours = 14
Minutess = 12
Secondss = 34
Milliseconds = 443
Finding the Start of Time Periods
One of the most common questions is how to remove the time from a datetime so that you end up with just a date. In other words, change 2006/12/13 02:33:48.347 to 2006/12/13 00:00:00.000. The following links have functions that will find the start of Century, Decade, Year, Quarter, Month, Week, Day, Hour, 30 Minutes, 20 Minutes, 15 Minutes, 10 Minutes , 5 Minutes , x number of Minutes ,Minute , or Second.
Start of Time Period Functions:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64755
Start of Week Function:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47307
Start of Week Function, Part Deux:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=59927
Convert DateTime to Date using Rounding UDF:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62354
Finding the End of Time Periods
Sometimes there is a need to find the last day of a time period. The following links have functions that will find the last day of Century, Decade, Year, Quarter, Month, or Week.
End Date of Time Period Functions:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64759
End of Week Function:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64760
Generating Date Tables
It can be very useful to have a table with a list of dates, and various attributes of those dates, especially for complex reporting. The functions on these links can be used to load a date table with many different columns of date attributes.
Date Table Function F_TABLE_DATE:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519
Here is another approach that also includes a function for calculating Easter. I haven’t tried it myself.
Create Date Table with UK & Easter bank holidays:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49711
Getting Time Only from DateTime
By convention, a time only column is stored in SQL Server as an offset from 1900-01-01 00:00:00.000. The function on this link will get the time from a datetime value.
Time Only Function: F_TIME_FROM_DATETIME
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65358
Finding Age
Computing the age of someone is more difficult than it might seem when you take into account different month lengths, leap year, and other things.
This function returns age in format YYYY MM DD.
Age Function F_AGE_YYYY_MM_DD:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62729
This function returns age in years.
Age Function F_AGE_IN_YEARS:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74462
This link is more of a discussion of the problem of calculating age than a script you can use, but it does show the difficulties. I haven’t tried it myself.
Calculating age in years:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=11578
Finding ISO Weeks
The ISO 8601 standard for dates defines a standard way of assigning a unique number to each week starting on Monday. The following functions can be used to return ISO weeks. The date table functions mentioned in the "Generating Date Tables" subject above also have columns for ISO weeks.
ISO Year Week Day of Week Function:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=60515
ISO Week of Year Function:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=60510
Converting Year, Month, and Day to DateTime
The functions on this link will take input parameters of Year, Month, and Day and return a datetime. There are several version posted.
Make Date function (like in VB):
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=22339
Converting to/from UNIX Time
The functions in this script can be used to convert to/from SQL Server date time to UNIX Time.
UNIX Time Conversion Functions:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=66858
Finding the midpoint between two datetimes
The function in this script finds the midpoint in time between two datetimes.
Datetime Range Midpoint Function
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=68806
Generating Random Datetimes
The functions on this link can be used to generate random datetimes, random integers, and random samples.
Random Integer, Sample, and Datetime Functions
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=69499
Creating a Formatted Calendar
There are several methods is this link that will return a result set with a formatted calendar.
Calender In Sql Server:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=44865
Links to other Date, Time, and Calendar Resources
This post has links to other resources for date and time information, as well as many other commonly asked questions about SQL Server.
FAQ - Frequently Given Answers:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210
This blog entry has links to various date time subjects.
Fun with Dates (Date Conversion examples):
http://weblogs.sqlteam.com/brettk/archive/2005/06/02/5528.aspx
This external link has a lot of information on the SQL Server datetime datatype, writing queries with datetime, and various datetime operations.
Demystifying the SQL Server DATETIME Datatype:
http://www.sql-server-performance.com/fk_datetime.asp
These external links are a series of articles about working about working with SQL Server Date/Time.
Working with SQL Server Date/Time Variables:
http://www.databasejournal.com/features/mssql/article.php/10894_2191631_1
Part Two - Displaying Dates and Times in Different Formats:
http://www.databasejournal.com/features/mssql/article.php/10894_2197931_1
Part Three - Searching for Particular Date Values and Ranges:
http://www.databasejournal.com/features/mssql/article.php/10894_2209321_1
Part Four - Date Math and Universal Time:
http://www.databasejournal.com/features/mssql/article.php/10894_2216011_1
This external link explains how the datetime datatypes work in SQL Server, including common pitfalls and general recommendations.
Guide to the datetime datatypes:
http://www.karaszi.com/SQLServer/info_datetime.asp
These external links discuss the ISO 8601 standards of dates and times.
Numeric representation of Dates and Time:
http://www.iso.org/iso/en/prods-services/popstds/datesandtime.html
ISO 8601:
http://en.wikipedia.org/wiki/ISO_8601
A summary of the international standard date and time notation:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
This external link explains how time is calculated on UNIX systems.
Unix Time:
http://en.wikipedia.org/wiki/Unix_time
These are external links to the U.S. Naval Observatory, an authority in the area of Precise Time.
The U.S. Naval Observatory Home:
http://www.usno.navy.mil/
The Official Standard of Time for the United States:
http://tycho.usno.navy.mil/
This external link has Clock, Calendar, Time Zone, and Holiday information for most of the world:
http://www.timeanddate.com/
This external link has a lot of information on the subject of Calendars.
Frequently Asked Questions about Calendars:
http://www.tondering.dk/claus/calendar.html
If you don't have any idea what all this is about,
You may need to Learn SQL:
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
And finally, the primary Microsoft SQL Server References:
SQL Server 2000 Books Online
http://msdn2.microsoft.com/en-us/library/aa257103(SQL.80).aspx
SQL Server 2005 Books Online
http://msdn2.microsoft.com/en-us/library/ms130214.aspx
CODO ERGO SUM
View 20 Replies
View Related
Nov 20, 2007
Hi all,
Heres the setup...
We have an asp application that runs the reportserver URL for the selected report, passing it through parameters. This opens the report viewer and the report runs.
The problem im having is that one report is not working as expected. When the report is run from report manager, everything works fine. The links do what they're meant to (they link to other reports passing through parameters). When the report is run from our asp application with the report viewer, the links fail.... they dont pass through the correct values or sometimes dont pass through a value at all.
Were the report viewer and report manager applications developed seperately?
Any help would be appreciated.
Thanks.
View 5 Replies
View Related