sql-server-2005

Passing Parameters to Stored Procedures using PyODBC

巧了我就是萌 提交于 2019-12-30 11:22:09
问题 I'm using pyODBC to connect to a SQL Server 2005 express database. I've created a stored procedure in SQLServer express that takes 2 string parameters e.g stored_proc(inpu1, input2) these parameters are of type datetime. I have tested the stored proc using management studio and it does return an appropriate result. However when i try to call the stored procedure from python(i'm using Eclipse) I get the error. pyodbc.DataError: ('22018', '[22018] [Microsoft][SQL Native Client]Invalid character

Can I do a very large insert with Linq-to-SQL?

泄露秘密 提交于 2019-12-30 11:09:01
问题 I've got some text data that I'm loading into a SQL Server 2005 database using Linq-to-SQL using this method (psuedo-code): Create a DataContext While (new data exists) { Read a record from the text file Create a new Record Populate the record dataContext.InsertOnSubmit(record); } dataContext.SubmitChanges(); The code is a little C# console application. This works fine so far, but I'm about to do an import of the real data (rather than a test subset) and this contains about 2 million rows

Can I do a very large insert with Linq-to-SQL?

南楼画角 提交于 2019-12-30 11:08:30
问题 I've got some text data that I'm loading into a SQL Server 2005 database using Linq-to-SQL using this method (psuedo-code): Create a DataContext While (new data exists) { Read a record from the text file Create a new Record Populate the record dataContext.InsertOnSubmit(record); } dataContext.SubmitChanges(); The code is a little C# console application. This works fine so far, but I'm about to do an import of the real data (rather than a test subset) and this contains about 2 million rows

Temp tables in SQL Server 2005 not automatically dropped

♀尐吖头ヾ 提交于 2019-12-30 11:08:29
问题 I'm troubleshooting a nasty stored procedure and noticed that after running it, and I have closed my session, lots of temp tables are still left in tempdb. They have names like the following: #000E262B #002334C4 #004E1D4D #00583EEE #00783A7F #00832777 #00CD403A #00E24ED3 #00F75D6C If I run this code: if object_id('tempdb..#000E262B') is null print 'Does NOT exist!' I get: Does NOT exist! If I do: use tempdb go drop TABLE #000E262B I get an error: Msg 3701, Level 11, State 5, Line 1 Cannot

Given year, month, day and week number how to find the date?(Sql Server 2005 Set based)

夙愿已清 提交于 2019-12-30 10:58:08
问题 Given year, month, day and week number how to find the date? e.g. year = 2010 month = Feb day = Wed week number = 4, how can I find that the date is 24/02/2010 Thanks 回答1: try this: --given info DECLARE @Year varchar(4) --= 2010 DECLARE @MonthName varchar(10) --= Feb DECLARE @WeekDayday varchar(10) --= Wed DECLARE @WeekNumber int --=4 SET @Year ='2010' SET @MonthName ='Feb' SET @WeekDayday ='Wed' SET @WeekNumber =4 --used to solve DECLARE @StartDate datetime ,@EndDate datetime ,@FirstWeek int

SQL Server 2005 - Find Which Stored Procs Run To A Particular Table

泄露秘密 提交于 2019-12-30 10:30:58
问题 Is there a quick way that I can find which stored procedures run to a particular table in my database? The database is very large with lots of tables and SPROCS.... 回答1: If you want to restrict the search to stored procedures then you can do this: SELECT name FROM sys.objects WHERE type = 'P' AND OBJECT_DEFINITION(object_id) LIKE '%name_of_your_table%' ORDER BY name If you wanted to include other SQL modules -- for examples, functions, triggers, views etc -- then you could alter the query to

SQL Server 2005 - Find Which Stored Procs Run To A Particular Table

佐手、 提交于 2019-12-30 10:30:06
问题 Is there a quick way that I can find which stored procedures run to a particular table in my database? The database is very large with lots of tables and SPROCS.... 回答1: If you want to restrict the search to stored procedures then you can do this: SELECT name FROM sys.objects WHERE type = 'P' AND OBJECT_DEFINITION(object_id) LIKE '%name_of_your_table%' ORDER BY name If you wanted to include other SQL modules -- for examples, functions, triggers, views etc -- then you could alter the query to

Why does SQL Server 2005 Dynamic Management View report a missing index when it is not?

穿精又带淫゛_ 提交于 2019-12-30 10:27:14
问题 I'm using SQL Server 2005 and the the Dynamic Management View sys.dm_db_missing_index_details . It continues to tell me that Table1 really needs an index on ColumnX and ColumnY, but that index already exists! I've even dropped and re-created it a couple times to no avail. More specifics: The view lists Column1 under equality_columns . Column2 is listed under inequality_columns , so the index I have created is: create index IndexA on Table1 (Column1 asc, Column2 asc) Isn't this exactly the

Search column in SQL database ignoring special characters

送分小仙女□ 提交于 2019-12-30 08:16:20
问题 Does anybody know if it's possible to do a %LIKE% search against a column in a SQL Server database but get it to ignore any special characters in the column? So, for example if I have a column called "songs" and they contain the following... Black Or White No Sleep 'till Brooklyn The Ship Song Papa Don't Preach If the user searches for "no sleey till brooklyn" then I would like it to return a match even though they forgot to include the apostrophe. I would also like it to return the 4th row

Can I search stored procedure results?

ε祈祈猫儿з 提交于 2019-12-30 08:13:08
问题 Let's say I have a stored procedure which returns a large set of data. Can I write another query to filter the result of stored procedure? For example: select * from EXEC xp_readerrorlog where LogDate = '2011-02-15' 回答1: You would need to first insert the results of the stored procedure on a table, and then query those results. create table #result (LogDate datetime, ProcessInfo varchar(20),Text text) INSERT INTO #Result EXEC xp_readerrorlog SELECT * FROM #Result WHERE datepart(yy,LogDate) =